Gradient calculation in different motion vector refinements

ABSTRACT

A video processing method is provided to include determining, for a current video block of a video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation based on a gradient of initial prediction samples according to a precision rule; and performing a conversion between the current video block and a coded representation using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure or a bi-directional optical flow (BDOF) procedure, wherein the precision rule specifies to use a same precision for representing the gradient for both the PROF procedure and the BDOF procedure.

CROSS REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No. 17/392,719, filed on Aug. 3, 2021, which is a continuation of International Application No. PCT/CN2020/085662, filed on Apr. 20, 2020, which claims the priority to and benefits of International Patent Application No. PCT/CN2019/083434, filed on Apr. 19, 2019, and International Patent Application No. PCT/CN2019/092762, filed on Jun. 25, 2019. The entire disclosures of the aforementioned applications are incorporated by reference as part of the disclosure of this application.

TECHNICAL FIELD

This patent document relates to video processing techniques, devices and systems.

BACKGROUND

In spite of the advances in video compression, digital video still accounts for the largest bandwidth use on the internet and other digital communication networks. As the number of connected user devices capable of receiving and displaying video increases, it is expected that the bandwidth demand for digital video usage will continue to grow.

SUMMARY

Devices, systems and methods related to digital video processing. The described methods may be applied to both the existing video coding standards (e.g., High Efficiency Video Coding (HEVC)) and future video coding standards or video codecs.

In one representative aspect, the disclosed technology may be used to provide a method for video processing. This method includes generating a prediction block for a current video block of a video using an affine mode motion compensation that is performed at a sub-block level of the current video block; performing a gradient calculation for a region of the current video block to refine the prediction block using a prediction refinement with optical flow (PROF) procedure, wherein a size of the region, (M×N), is different from a size of a sub-block of the current video block, wherein M and N are positive integers; and performing, based on the gradient calculation, a conversion between the current video block and a coded representation of the video.

In another representative aspect, the disclosed technology may be used to provide a method for video processing. This method includes deriving, for a current video block of a video having a first size, a final prediction block that is computed by refining one or more intermediate prediction blocks using a gradient calculation performed on video regions having a second size according to a rule, wherein the refining uses an optical flow procedure; and performing a conversion between the current video block and a coded representation of the video using the final prediction block.

In another representative aspect, the disclosed technology may be used to provide a method for video processing. This method includes deriving, for a current video block of a video, motion information using a bidirectional optical flow (BDOF) or a prediction refinement with optical flow (PROF); performing a gradient calculation for samples in a region of the current video block such that at least one sample in the region is omitted from the gradient calculation; and performing, based on the gradient calculation, a conversion between the current video block and a coded representation of a video comprising the current video block, wherein one or more initial predictions for the current video block are computed at a sub-block level and refined using an optical flow calculation during the PROF or the one or more initial predictions are refined using a spatial and a temporal gradient during the BDOF.

In another representative aspect, the disclosed technology may be used to provide a method for video processing. This method includes determining, for a current video block of a video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation based on a gradient of initial prediction samples according to a precision rule; and performing a conversion between the current video block and a coded representation using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure or a bi-directional optical flow (BDOF) procedure, wherein the precision rule specifies to use a same precision for representing the gradient for both the PROF procedure and the BDOF procedure.

In another representative aspect, the disclosed technology may be used to provide a method for video processing. This method includes determining, for conversion between a current video block of a video and a coded representation of the video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation; and performing the conversion using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure and/or a bi-directional optical flow (BDOF) procedure, wherein the optical flow calculation further includes a padding operation applicable to at least one of the PROF procedure or the BDOF procedure according to a rule to derive padding samples.

In yet another representative aspect, the above-described method is embodied in the form of processor-executable code and stored in a computer-readable program medium.

In yet another representative aspect, a device that is configured or operable to perform the above-described method is disclosed. The device may include a processor that is programmed to implement this method.

In yet another representative aspect, a video decoder apparatus may implement a method as described herein.

The above and other aspects and features of the disclosed technology are described in greater detail in the drawings, the description and the claims.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 shows an example of constructing a merge candidate list.

FIG. 2 shows an example of positions of spatial candidates.

FIG. 3 shows an example of candidate pairs subject to a redundancy check of spatial merge candidates.

FIGS. 4A and 4B show examples of the position of a second prediction unit (PU) based on the size and shape of the current block.

FIG. 5 shows an example of motion vector scaling for temporal merge candidates.

FIG. 6 shows an example of candidate positions for temporal merge candidates.

FIG. 7 shows an example of generating a combined bi-predictive merge candidate.

FIG. 8 shows an example of constructing motion vector prediction candidates.

FIG. 9 shows an example of motion vector scaling for spatial motion vector candidates.

FIG. 10 shows an example of motion prediction using the alternative temporal motion vector prediction (ATMVP) algorithm for a coding unit (CU).

FIG. 11 shows an example of a coding unit (CU) with sub-blocks and neighboring blocks used by the spatial-temporal motion vector prediction (STMVP) algorithm.

FIGS. 12A and 12B show example snapshots of sub-block when using the overlapped block motion compensation (OBMC) algorithm.

FIG. 13 shows an example of neighboring samples used to derive parameters for the local illumination compensation (LIC) algorithm.

FIG. 14 shows an example of a simplified affine motion model.

FIG. 15 shows an example of an affine motion vector field (MVF) per sub-block.

FIG. 16 shows an example of motion vector prediction (MVP) for the AF_INTER affine motion mode.

FIGS. 17A and 17B show example candidates for the AF_MERGE affine motion mode.

FIG. 18 shows an example of bilateral matching in pattern matched motion vector derivation (PMMVD) mode, which is a special merge mode based on the frame-rate up conversion (FRUC) algorithm.

FIG. 19 shows an example of template matching in the FRUC algorithm.

FIG. 20 shows an example of unilateral motion estimation in the FRUC algorithm.

FIG. 21 shows an example of an optical flow trajectory used by the bi-directional optical flow (BIO) algorithm.

FIGS. 22A and 22B show example snapshots of using of the bi-directional optical flow (BIO) algorithm without block extensions.

FIG. 23 shows an example of the interpolated samples used in BIO.

FIG. 24 shows an example of the decoder-side motion vector refinement (DMVR) algorithm based on bilateral template matching.

FIG. 25 shows an example of a sub-block MV VSB and pixel Δv(i,j).

FIG. 26 shows an example of phase-variant horizontal filtering.

FIG. 27 shows an example of applying one instance of 8-tap horizontal filtering.

FIG. 28 shows an example of non-uniform phase vertical filtering.

FIGS. 29A to 29E show flowcharts of an example method for video processing.

FIGS. 30A and 30B are block diagrams of examples of a hardware platform for implementing a visual media decoding or a visual media encoding technique described in the present document.

FIG. 31 shows an example of 164×4 sub-blocks in a 16×16 region.

DETAILED DESCRIPTION

Due to the increasing demand of higher resolution video, video processing methods and techniques are ubiquitous in modern technology. Video codecs typically include an electronic circuit or software that compresses or decompresses digital video, and are continually being improved to provide higher coding efficiency. A video codec converts uncompressed video to a compressed format or vice versa. There are complex relationships between the video quality, the amount of data used to represent the video (determined by the bit rate), the complexity of the encoding and decoding algorithms, sensitivity to data losses and errors, ease of editing, random access, and end-to-end delay (latency). The compressed format usually conforms to a standard video compression specification, e.g., the High Efficiency Video Coding (HEVC) standard (also known as H.265 or MPEG-H Part 2), the Versatile Video Coding standard to be finalized, or other current and/or future video coding standards.

Embodiments of the disclosed technology may be applied to existing video coding standards (e.g., HEVC, H.265) and future standards to improve compression performance. Section headings are used in the present document to improve readability of the description and do not in any way limit the discussion or the embodiments (and/or implementations) to the respective sections only.

1. Examples of Inter-Prediction in HEVC/H.265

Video coding standards have significantly improved over the years, and now provide, in part, high coding efficiency and support for higher resolutions. Recent standards such as HEVC and H.265 are based on the hybrid video coding structure wherein temporal prediction plus transform coding are utilized.

1.1 Examples of Prediction Modes

Each inter-predicted PU (prediction unit) has motion parameters for one or two reference picture lists. In some embodiments, motion parameters include a motion vector and a reference picture index. In other embodiments, the usage of one of the two reference picture lists may also be signaled using inter_pred_idc. In yet other embodiments, motion vectors may be explicitly coded as deltas relative to predictors.

When a CU is coded with skip mode, one PU is associated with the CU, and there are no significant residual coefficients, no coded motion vector delta or reference picture index. A merge mode is specified whereby the motion parameters for the current PU are obtained from neighboring PUs, including spatial and temporal candidates. The merge mode can be applied to any inter-predicted PU, not only for skip mode. The alternative to merge mode is the explicit transmission of motion parameters, where motion vector, corresponding reference picture index for each reference picture list and reference picture list usage are signaled explicitly per each PU.

When signaling indicates that one of the two reference picture lists is to be used, the PU is produced from one block of samples. This is referred to as ‘uni-prediction’. Uni-prediction is available both for P-slices and B-slices.

When signaling indicates that both of the reference picture lists are to be used, the PU is produced from two blocks of samples. This is referred to as ‘bi-prediction’. Bi-prediction is available for B-slices only.

1.1.1 Embodiments of Constructing Candidates for Merge Mode

When a PU is predicted using merge mode, an index pointing to an entry in the merge candidates list is parsed from the bitstream and used to retrieve the motion information. The construction of this list can be summarized according to the following sequence of steps:

Step 1: Initial candidates derivation

-   -   Step 1.1: Spatial candidates derivation     -   Step 1.2: Redundancy check for spatial candidates     -   Step 1.3: Temporal candidates derivation

Step 2: Additional candidates insertion

-   -   Step 2.1: Creation of bi-predictive candidates     -   Step 2.2: Insertion of zero motion candidates

FIG. 1 shows an example of constructing a merge candidate list based on the sequence of steps summarized above. For spatial merge candidate derivation, a maximum of four merge candidates are selected among candidates that are located in five different positions. For temporal merge candidate derivation, a maximum of one merge candidate is selected among two candidates. Since constant number of candidates for each PU is assumed at decoder, additional candidates are generated when the number of candidates does not reach to maximum number of merge candidate (MaxNumMergeCand) which is signalled in slice header. Since the number of candidates is constant, index of best merge candidate is encoded using truncated unary binarization (TU). If the size of CU is equal to 8, all the PUs of the current CU share a single merge candidate list, which is identical to the merge candidate list of the 2N×2N prediction unit.

1.1.2 Constructing Spatial Merge Candidates

In the derivation of spatial merge candidates, a maximum of four merge candidates are selected among candidates located in the positions depicted in FIG. 2. The order of derivation is A₁, B₁, B₀, A₀ and B₂. Position B₂ is considered only when any PU of position A₁, B₁, B₀, A₀ is not available (e.g. because it belongs to another slice or tile) or is intra coded. After candidate at position A₁ is added, the addition of the remaining candidates is subject to a redundancy check which ensures that candidates with same motion information are excluded from the list so that coding efficiency is improved.

To reduce computational complexity, not all possible candidate pairs are considered in the mentioned redundancy check. Instead only the pairs linked with an arrow in FIG. 3 are considered and a candidate is only added to the list if the corresponding candidate used for redundancy check has not the same motion information. Another source of duplicate motion information is the “second PU” associated with partitions different from 2N×2N. As an example, FIGS. 4A and 4B depict the second PU for the case of N×2N and 2N×N, respectively. When the current PU is partitioned as N×2N, candidate at position A₁ is not considered for list construction. In some embodiments, adding this candidate may lead to two prediction units having the same motion information, which is redundant to just have one PU in a coding unit. Similarly, position B₁ is not considered when the current PU is partitioned as 2N×N.

1.1.3 Constructing Temporal Merge Candidates

In this step, only one candidate is added to the list. Particularly, in the derivation of this temporal merge candidate, a scaled motion vector is derived based on co-located PU belonging to the picture which has the smallest POC difference with current picture within the given reference picture list. The reference picture list to be used for derivation of the co-located PU is explicitly signaled in the slice header.

FIG. 5 shows an example of the derivation of the scaled motion vector for a temporal merge candidate (as the dotted line), which is scaled from the motion vector of the co-located PU using the POC distances, tb and td, where tb is defined to be the POC difference between the reference picture of the current picture and the current picture and td is defined to be the POC difference between the reference picture of the co-located picture and the co-located picture. The reference picture index of temporal merge candidate is set equal to zero. For a B-slice, two motion vectors, one is for reference picture list 0 and the other is for reference picture list 1, are obtained and combined to make the bi-predictive merge candidate.

In the co-located PU (Y) belonging to the reference frame, the position for the temporal candidate is selected between candidates C₀ and C₁, as depicted in FIG. 6. If PU at position C₀ is not available, is intra coded, or is outside of the current CTU, position C₁ is used. Otherwise, position C₀ is used in the derivation of the temporal merge candidate.

1.1.4 Constructing Additional Types of Merge Candidates

Besides spatio-temporal merge candidates, there are two additional types of merge candidates: combined bi-predictive merge candidate and zero merge candidate. Combined bi-predictive merge candidates are generated by utilizing spatio-temporal merge candidates. Combined bi-predictive merge candidate is used for B-Slice only. The combined bi-predictive candidates are generated by combining the first reference picture list motion parameters of an initial candidate with the second reference picture list motion parameters of another. If these two tuples provide different motion hypotheses, they will form a new bi-predictive candidate.

FIG. 7 shows an example of this process, wherein two candidates in the original list (710, on the left), which have mvL0 and refIdxL0 or mvL1 and refIdxL1, are used to create a combined bi-predictive merge candidate added to the final list (720, on the right).

Zero motion candidates are inserted to fill the remaining entries in the merge candidates list and therefore hit the MaxNumMergeCand capacity. These candidates have zero spatial displacement and a reference picture index which starts from zero and increases every time a new zero motion candidate is added to the list. The number of reference frames used by these candidates is one and two for uni- and bi-directional prediction, respectively. In some embodiments, no redundancy check is performed on these candidates.

1.1.5 Examples of Motion Estimation Regions for Parallel Processing

To speed up the encoding process, motion estimation can be performed in parallel whereby the motion vectors for all prediction units inside a given region are derived simultaneously. The derivation of merge candidates from spatial neighborhood may interfere with parallel processing as one prediction unit cannot derive the motion parameters from an adjacent PU until its associated motion estimation is completed. To mitigate the trade-off between coding efficiency and processing latency, a motion estimation region (MER) may be defined. The size of the MER may be signaled in the picture parameter set (PPS) using the “log 2_parallel_merge_level_minus2” syntax element. When a MER is defined, merge candidates falling in the same region are marked as unavailable and therefore not considered in the list construction.

1.2 Embodiments of Advanced Motion Vector Prediction (AMVP)

AMVP exploits spatio-temporal correlation of motion vector with neighboring PUs, which is used for explicit transmission of motion parameters. It constructs a motion vector candidate list by firstly checking availability of left, above temporally neighboring PU positions, removing redundant candidates and adding zero vector to make the candidate list to be constant length. Then, the encoder can select the best predictor from the candidate list and transmit the corresponding index indicating the chosen candidate. Similarly with merge index signaling, the index of the best motion vector candidate is encoded using truncated unary. The maximum value to be encoded in this case is 2 (see FIG. 8). In the following sections, details about derivation process of motion vector prediction candidate are provided.

1.2.1 Examples of Constructing Motion Vector Prediction Candidates

FIG. 8 summarizes derivation process for motion vector prediction candidate, and may be implemented for each reference picture list with refidx as an input.

In motion vector prediction, two types of motion vector candidates are considered: spatial motion vector candidate and temporal motion vector candidate. For spatial motion vector candidate derivation, two motion vector candidates are eventually derived based on motion vectors of each PU located in five different positions as previously shown in FIG. 2.

For temporal motion vector candidate derivation, one motion vector candidate is selected from two candidates, which are derived based on two different co-located positions. After the first list of spatio-temporal candidates is made, duplicated motion vector candidates in the list are removed. If the number of potential candidates is larger than two, motion vector candidates whose reference picture index within the associated reference picture list is larger than 1 are removed from the list. If the number of spatio-temporal motion vector candidates is smaller than two, additional zero motion vector candidates is added to the list.

1.2.2 Constructing Spatial Motion Vector Candidates

In the derivation of spatial motion vector candidates, a maximum of two candidates are considered among five potential candidates, which are derived from PUs located in positions as previously shown in FIG. 2, those positions being the same as those of motion merge. The order of derivation for the left side of the current PU is defined as A₀, A₁, and scaled A₀, scaled A₁. The order of derivation for the above side of the current PU is defined as B₀, B₁, B₂, scaled B₀, scaled B₁, scaled B₂. For each side there are therefore four cases that can be used as motion vector candidate, with two cases not required to use spatial scaling, and two cases where spatial scaling is used. The four different cases are summarized as follows:

No Spatial Scaling

-   -   (1) Same reference picture list, and same reference picture         index (same POC)     -   (2) Different reference picture list, but same reference picture         (same POC)

Spatial Scaling

-   -   (3) Same reference picture list, but different reference picture         (different POC)     -   (4) Different reference picture list, and different reference         picture (different POC)

The no-spatial-scaling cases are checked first followed by the cases that allow spatial scaling. Spatial scaling is considered when the POC is different between the reference picture of the neighbouring PU and that of the current PU regardless of reference picture list. If all PUs of left candidates are not available or are intra coded, scaling for the above motion vector is allowed to help parallel derivation of left and above V candidates. Otherwise, spatial scaling is not allowed for the above motion vector.

As shown in the example in FIG. 9, for the spatial scaling case, the motion vector of the neighbouring PU is scaled in a similar manner as for temporal scaling. One difference is that the reference picture list and index of current PU is given as input; the actual scaling process is the same as that of temporal scaling.

1.2.3 Constructing Temporal Motion Vector Candidates

Apart from the reference picture index derivation, all processes for the derivation of temporal merge candidates are the same as for the derivation of spatial motion vector candidates (as shown in the example in FIG. 6). In some embodiments, the reference picture index is signaled to the decoder.

2. Example of Inter Prediction Methods in Joint Exploration Model (JEM)

In some embodiments, future video coding technologies are explored using a reference software known as the Joint Exploration Model (JEM). In JEM, sub-block based prediction is adopted in several coding tools, such as affine prediction, alternative temporal motion vector prediction (ATMVP), spatial-temporal motion vector prediction (STMVP), bi-directional optical flow (BIO), Frame-Rate Up Conversion (FRUC), Locally Adaptive Motion Vector Resolution (LAMVR), Overlapped Block Motion Compensation (OBMC), Local Illumination Compensation (LIC), and Decoder-side Motion Vector Refinement (DMVR).

2.1 Examples of Sub-CU Based Motion Vector Prediction

In the JEM with quadtrees plus binary trees (QTBT), each CU can have at most one set of motion parameters for each prediction direction. In some embodiments, two sub-CU level motion vector prediction methods are considered in the encoder by splitting a large CU into sub-CUs and deriving motion information for all the sub-CUs of the large CU. Alternative temporal motion vector prediction (ATMVP) method allows each CU to fetch multiple sets of motion information from multiple blocks smaller than the current CU in the collocated reference picture. In spatial-temporal motion vector prediction (STMVP) method motion vectors of the sub-CUs are derived recursively by using the temporal motion vector predictor and spatial neighbouring motion vector. In some embodiments, and to preserve more accurate motion field for sub-CU motion prediction, the motion compression for the reference frames may be disabled.

2.1.1 Examples of Alternative Temporal Motion Vector Prediction (ATMVP)

In the ATMVP method, the temporal motion vector prediction (TMVP) method is modified by fetching multiple sets of motion information (including motion vectors and reference indices) from blocks smaller than the current CU.

FIG. 10 shows an example of ATMVP motion prediction process for a CU 1000. The ATMVP method predicts the motion vectors of the sub-CUs 1001 within a CU 1000 in two steps. The first step is to identify the corresponding block 1051 in a reference picture 1050 with a temporal vector. The reference picture 1050 is also referred to as the motion source picture. The second step is to split the current CU 1000 into sub-CUs 1001 and obtain the motion vectors as well as the reference indices of each sub-CU from the block corresponding to each sub-CU.

In the first step, a reference picture 1050 and the corresponding block is determined by the motion information of the spatial neighboring blocks of the current CU 1000. To avoid the repetitive scanning process of neighboring blocks, the first merge candidate in the merge candidate list of the current CU 1000 is used. The first available motion vector as well as its associated reference index are set to be the temporal vector and the index to the motion source picture. This way, the corresponding block may be more accurately identified, compared with TMVP, wherein the corresponding block (sometimes called collocated block) is always in a bottom-right or center position relative to the current CU.

In the second step, a corresponding block of the sub-CU 1051 is identified by the temporal vector in the motion source picture 1050, by adding to the coordinate of the current CU the temporal vector. For each sub-CU, the motion information of its corresponding block (e.g., the smallest motion grid that covers the center sample) is used to derive the motion information for the sub-CU. After the motion information of a corresponding N×N block is identified, it is converted to the motion vectors and reference indices of the current sub-CU, in the same way as TMVP of HEVC, wherein motion scaling and other procedures apply. For example, the decoder checks whether the low-delay condition (e.g. the POCs of all reference pictures of the current picture are smaller than the POC of the current picture) is fulfilled and possibly uses motion vector MVx (e.g., the motion vector corresponding to reference picture list X) to predict motion vector MVy (e.g., with X being equal to 0 or 1 and Y being equal to 1−X) for each sub-CU.

2.1.2 Examples of Spatial-Temporal Motion Vector Prediction (STMVP)

In the STMVP method, the motion vectors of the sub-CUs are derived recursively, following raster scan order. FIG. 11 shows an example of one CU with four sub-blocks and neighboring blocks. Consider an 8×8 CU 1100 that includes four 4×4 sub-CUs A (1101), B (1102), C (1103), and D (1104). The neighboring 4×4 blocks in the current frame are labelled as a (1111), b (1112), c (1113), and d (1114).

The motion derivation for sub-CU A starts by identifying its two spatial neighbors. The first neighbor is the N×N block above sub-CU A 1101 (block c 1113). If this block c (1113) is not available or is intra coded the other N×N blocks above sub-CU A (1101) are checked (from left to right, starting at block c 1113). The second neighbor is a block to the left of the sub-CU A 1101 (block b 1112). If block b (1112) is not available or is intra coded other blocks to the left of sub-CU A 1101 are checked (from top to bottom, staring at block b 1112). The motion information obtained from the neighboring blocks for each list is scaled to the first reference frame for a given list. Next, temporal motion vector predictor (TMVP) of sub-block A 1101 is derived by following the same procedure of TMVP derivation as specified in HEVC. The motion information of the collocated block at block D 1104 is fetched and scaled accordingly. Finally, after retrieving and scaling the motion information, all available motion vectors are averaged separately for each reference list. The averaged motion vector is assigned as the motion vector of the current sub-CU.

2.1.3 Examples of Sub-CU Motion Prediction Mode Signaling

In some embodiments, the sub-CU modes are enabled as additional merge candidates and there is no additional syntax element required to signal the modes. Two additional merge candidates are added to merge candidates list of each CU to represent the ATMVP mode and STMVP mode. In other embodiments, up to seven merge candidates may be used, if the sequence parameter set indicates that ATMVP and STMVP are enabled. The encoding logic of the additional merge candidates is the same as for the merge candidates in the HM, which means, for each CU in P or B slice, two more RD checks may be needed for the two additional merge candidates. In some embodiments, e.g., JEM, all bins of the merge index are context coded by CABAC (Context-based Adaptive Binary Arithmetic Coding). In other embodiments, e.g., HEVC, only the first bin is context coded and the remaining bins are context by-pass coded.

2.2 Examples of Adaptive Motion Vector Difference Resolution

In some embodiments, motion vector differences (MVDs) (between the motion vector and predicted motion vector of a PU) are signalled in units of quarter luma samples when use_integer_mv_flag is equal to 0 in the slice header. In the JEM, a locally adaptive motion vector resolution (LAMVR) is introduced. In the JEM, MVD can be coded in units of quarter luma samples, integer luma samples or four luma samples. The MVD resolution is controlled at the coding unit (CU) level, and MVD resolution flags are conditionally signalled for each CU that has at least one non-zero MVD components.

For a CU that has at least one non-zero MVD components, a first flag is signalled to indicate whether quarter luma sample MV precision is used in the CU. When the first flag (equal to 1) indicates that quarter luma sample MV precision is not used, another flag is signalled to indicate whether integer luma sample MV precision or four luma sample MV precision is used.

When the first MVD resolution flag of a CU is zero, or not coded for a CU (meaning all MVDs in the CU are zero), the quarter luma sample MV resolution is used for the CU. When a CU uses integer-luma sample MV precision or four-luma-sample MV precision, the MVPs in the AMVP candidate list for the CU are rounded to the corresponding precision.

In the encoder, CU-level RD checks are used to determine which MVD resolution is to be used for a CU. That is, the CU-level RD check is performed three times for each MVD resolution. To accelerate encoder speed, the following encoding schemes are applied in the JEM:

-   -   During RD check of a CU with normal quarter luma sample MVD         resolution, the motion information of the current CU (integer         luma sample accuracy) is stored. The stored motion information         (after rounding) is used as the starting point for further small         range motion vector refinement during the RD check for the same         CU with integer luma sample and 4 luma sample MVD resolution so         that the time-consuming motion estimation process is not         duplicated three times.     -   RD check of a CU with 4 luma sample MVD resolution is         conditionally invoked. For a CU, when RD cost integer luma         sample MVD resolution is much larger than that of quarter luma         sample MVD resolution, the RD check of 4 luma sample MVD         resolution for the CU is skipped.

2.3 Examples of Higher Motion Vector Storage Accuracy

In HEVC, motion vector accuracy is one-quarter pel (one-quarter luma sample and one-eighth chroma sample for 4:2:0 video). In the JEM, the accuracy for the internal motion vector storage and the merge candidate increases to 1/16 pel. The higher motion vector accuracy ( 1/16 pel) is used in motion compensation inter prediction for the CU coded with skip/merge mode. For the CU coded with normal AMVP mode, either the integer-pel or quarter-pel motion is used.

SHVC up sampling interpolation filters, which have same filter length and normalization factor as HEVC motion compensation interpolation filters, are used as motion compensation interpolation filters for the additional fractional pel positions. The chroma component motion vector accuracy is 1/32 sample in the JEM, the additional interpolation filters of 1/32 pel fractional positions are derived by using the average of the filters of the two neighbouring 1/16 pel fractional positions.

2.4 Examples of Overlapped Block Motion Compensation (OBMC)

In the JEM, OBMC can be switched on and off using syntax at the CU level. When OBMC is used in the JEM, the OBMC is performed for all motion compensation (MC) block boundaries except the right and bottom boundaries of a CU. Moreover, it is applied for both the luma and chroma components. In the JEM, an MC block corresponds to a coding block. When a CU is coded with sub-CU mode (includes sub-CU merge, affine and FRUC mode), each sub-block of the CU is a MC block. To process CU boundaries in a uniform fashion, OBMC is performed at sub-block level for all MC block boundaries, where sub-block size is set equal to 4×4, as shown in FIGS. 12A and 12B.

FIG. 12A shows sub-blocks at the CU/PU boundary, and the hatched sub-blocks are where OBMC applies. Similarly, FIG. 12B shows the sub-Pus in ATMVP mode.

When OBMC applies to the current sub-block, besides current motion vectors, motion vectors of four connected neighboring sub-blocks, if available and are not identical to the current motion vector, are also used to derive prediction block for the current sub-block. These multiple prediction blocks based on multiple motion vectors are combined to generate the final prediction signal of the current sub-block.

Prediction block based on motion vectors of a neighboring sub-block is denoted as PN, with N indicating an index for the neighboring above, below, left and right sub-blocks and prediction block based on motion vectors of the current sub-block is denoted as PC. When PN is based on the motion information of a neighboring sub-block that contains the same motion information to the current sub-block, the OBMC is not performed from PN. Otherwise, every sample of PN is added to the same sample in PC, i.e., four rows/columns of PN are added to PC. The weighting factors {¼, ⅛, 1/16, 1/32} are used for PN and the weighting factors {¾, ⅞, 15/16, 31/32} are used for PC. The exception are small MC blocks, (i.e., when height or width of the coding block is equal to 4 or a CU is coded with sub-CU mode), for which only two rows/columns of PN are added to PC. In this case weighting factors {¼, ⅛} are used for PN and weighting factors {¾, ⅞} are used for PC. For PN generated based on motion vectors of vertically (horizontally) neighboring sub-block, samples in the same row (column) of PN are added to PC with a same weighting factor.

In the JEM, for a CU with size less than or equal to 256 luma samples, a CU level flag is signaled to indicate whether OBMC is applied or not for the current CU. For the CUs with size larger than 256 luma samples or not coded with AMVP mode, OBMC is applied by default. At the encoder, when OBMC is applied for a CU, its impact is taken into account during the motion estimation stage. The prediction signal formed by OBMC using motion information of the top neighboring block and the left neighboring block is used to compensate the top and left boundaries of the original signal of the current CU, and then the normal motion estimation process is applied.

2.5 Examples of Local Illumination Compensation (LIC)

LIC is based on a linear model for illumination changes, using a scaling factor a and an offset b. And it is enabled or disabled adaptively for each inter-mode coded coding unit (CU).

When LIC applies for a CU, a least square error method is employed to derive the parameters a and b by using the neighboring samples of the current CU and their corresponding reference samples. FIG. 13 shows an example of neighboring samples used to derive parameters of the IC algorithm. Specifically, and as shown in FIG. 13, the subsampled (2:1 subsampling) neighbouring samples of the CU and the corresponding samples (identified by motion information of the current CU or sub-CU) in the reference picture are used. The IC parameters are derived and applied for each prediction direction separately.

When a CU is coded with merge mode, the LIC flag is copied from neighboring blocks, in a way similar to motion information copy in merge mode; otherwise, an LIC flag is signaled for the CU to indicate whether LIC applies or not.

When LIC is enabled for a picture, an additional CU level RD check is needed to determine whether LIC is applied or not for a CU. When LIC is enabled for a CU, the mean-removed sum of absolute difference (MR-SAD) and mean-removed sum of absolute Hadamard-transformed difference (MR-SATD) are used, instead of SAD and SATD, for integer pel motion search and fractional pel motion search, respectively.

To reduce the encoding complexity, the following encoding scheme is applied in the JEM:

-   -   LIC is disabled for the entire picture when there is no obvious         illumination change between a current picture and its reference         pictures. To identify this situation, histograms of a current         picture and every reference picture of the current picture are         calculated at the encoder. If the histogram difference between         the current picture and every reference picture of the current         picture is smaller than a given threshold, LIC is disabled for         the current picture; otherwise, LIC is enabled for the current         picture.

2.6 Examples of Affine Motion Compensation Prediction

In HEVC, only a translation motion model is applied for motion compensation prediction (MCP). However, the camera and objects may have many kinds of motion, e.g. zoom in/out, rotation, perspective motions, and/or other irregular motions. JEM, on the other hand, applies a simplified affine transform motion compensation prediction. FIG. 14 shows an example of an affine motion field of a block 1400 described by two control point motion vectors V₀ and V₁. The motion vector field (MVF) of the block 1400 can be described by the following equation:

$\begin{matrix} \left\{ \begin{matrix} {v_{x} = {{\frac{\left( {v_{1x} - v_{0x}} \right)}{w}x} - {\frac{\left( {v_{1y} - v_{0y}} \right)}{w}y} + v_{0x}}} \\ {v_{y} = {{\frac{\left( {v_{1y} - v_{0y}} \right)}{w}x} + {\frac{\left( {v_{1x} - v_{0x}} \right)}{w}y} + v_{0y}}} \end{matrix} \right. & {{Eq}.\mspace{14mu}(1)} \end{matrix}$

As shown in FIG. 14, (v_(0x), v_(0y)) is motion vector of the top-left corner control point, and (v_(1x), v_(1y)) is motion vector of the top-right corner control point. To simplify the motion compensation prediction, sub-block based affine transform prediction can be applied. The sub-block size M×N is derived as follows:

$\begin{matrix} \left\{ \begin{matrix} {M = {{clip}\; 3\left( {4,w,\frac{w \times MvPre}{\max\left( {{{abs}\left( {v_{1x} - v_{0x}} \right)},{{abs}\left( {v_{1y} - v_{0y}} \right)}} \right)}} \right)}} \\ {N = {clip3\left( {4,h,\ \frac{h \times MvPre}{\max\left( {{{abs}\left( {v_{2x} - v_{0x}} \right)},{{abs}\left( {v_{2y} - v_{0y}} \right)}} \right)}} \right)}} \end{matrix} \right. & {{Eq}.\mspace{14mu}(2)} \end{matrix}$

Here, MvPre is the motion vector fraction accuracy (e.g., 1/16 in JEM). (v_(2x), v_(2y)) is motion vector of the bottom-left control point, calculated according to Eq. (1). M and N can be adjusted downward if necessary to make it a divisor of w and h, respectively.

FIG. 15 shows an example of affine MVF per sub-block for a block 1500. To derive motion vector of each M×N sub-block, the motion vector of the center sample of each sub-block can be calculated according to Eq. (1), and rounded to the motion vector fraction accuracy (e.g., 1/16 in JEM). Then the motion compensation interpolation filters can be applied to generate the prediction of each sub-block with derived motion vector. After the MCP, the high accuracy motion vector of each sub-block is rounded and saved as the same accuracy as the normal motion vector.

2.6.1 Embodiments of the AF_INTER Mode

In the JEM, there are two affine motion modes: AF_INTER mode and AF_MERGE mode. For CUs with both width and height larger than 8, AF_INTER mode can be applied. An affine flag in CU level is signaled in the bitstream to indicate whether AF_INTER mode is used. In the AF_INTER mode, a candidate list with motion vector pair {(v₀,v₁)|v₀={v_(A), v_(B), v_(c)}, v₁{v_(D),v_(E)}} is constructed using the neighboring blocks.

FIG. 16 shows an example of motion vector prediction (MVP) for a block 1600 in the AF_INTER mode. As shown in FIG. 16, v₀ is selected from the motion vectors of the sub-block A, B, or C. The motion vectors from the neighboring blocks can be scaled according to the reference list. The motion vectors can also be scaled according to the relationship among the Picture Order Count (POC) of the reference for the neighboring block, the POC of the reference for the current CU, and the POC of the current CU. The approach to select v₁ from the neighboring sub-block D and E is similar. If the number of candidate list is smaller than 2, the list is padded by the motion vector pair composed by duplicating each of the AMVP candidates. When the candidate list is larger than 2, the candidates can be firstly sorted according to the neighboring motion vectors (e.g., based on the similarity of the two motion vectors in a pair candidate). In some implementations, the first two candidates are kept. In some embodiments, a Rate Distortion (RD) cost check is used to determine which motion vector pair candidate is selected as the control point motion vector prediction (CPMVP) of the current CU. An index indicating the position of the CPMVP in the candidate list can be signaled in the bitstream. After the CPMVP of the current affine CU is determined, affine motion estimation is applied and the control point motion vector (CPMV) is found. Then the difference of the CPMV and the CPMVP is signaled in the bitstream.

2.6.3 Embodiments of the AF_MERGE Mode

When a CU is applied in AF_MERGE mode, it gets the first block coded with an affine mode from the valid neighboring reconstructed blocks. FIG. 17A shows an example of the selection order of candidate blocks for a current CU 1700. As shown in FIG. 17A, the selection order can be from left (1701), above (1702), above right (1703), left bottom (1704) to above left (1705) of the current CU 1700. FIG. 17B shows another example of candidate blocks for a current CU 1700 in the AF_MERGE mode. If the neighboring left bottom block 1801 is coded in affine mode, as shown in FIG. 17B, the motion vectors v₂, v₃ and v₄ of the top left corner, above right corner, and left bottom corner of the CU containing the sub-block 1701 are derived. The motion vector v₀ of the top left corner on the current CU 1700 is calculated based on v2, v3 and v4. The motion vector v1 of the above right of the current CU can be calculated accordingly.

After the CPMV of the current CU v0 and v1 are computed according to the affine motion model in Eq. (1), the MVF of the current CU can be generated. In order to identify whether the current CU is coded with AF_MERGE mode, an affine flag can be signaled in the bitstream when there is at least one neighboring block is coded in affine mode.

2.7 Examples of Pattern Matched Motion Vector Derivation (PMMVD)

The PMMVD mode is a special merge mode based on the Frame-Rate Up Conversion (FRUC) method. With this mode, motion information of a block is not signaled but derived at decoder side.

A FRUC flag can be signaled for a CU when its merge flag is true. When the FRUC flag is false, a merge index can be signaled and the regular merge mode is used. When the FRUC flag is true, an additional FRUC mode flag can be signaled to indicate which method (e.g., bilateral matching or template matching) is to be used to derive motion information for the block.

At the encoder side, the decision on whether using FRUC merge mode for a CU is based on RD cost selection as done for normal merge candidate. For example, multiple matching modes (e.g., bilateral matching and template matching) are checked for a CU by using RD cost selection. The one leading to the minimal cost is further compared to other CU modes. If a FRUC matching mode is the most efficient one, FRUC flag is set to true for the CU and the related matching mode is used.

Typically, motion derivation process in FRUC merge mode has two steps: a CU-level motion search is first performed, then followed by a Sub-CU level motion refinement. At CU level, an initial motion vector is derived for the whole CU based on bilateral matching or template matching. First, a list of MV candidates is generated and the candidate that leads to the minimum matching cost is selected as the starting point for further CU level refinement. Then a local search based on bilateral matching or template matching around the starting point is performed. The MV results in the minimum matching cost is taken as the MV for the whole CU. Subsequently, the motion information is further refined at sub-CU level with the derived CU motion vectors as the starting points.

For example, the following derivation process is performed for a W×H CU motion information derivation. At the first stage, MV for the whole W×H CU is derived. At the second stage, the CU is further split into M×M sub-CUs. The value of M is calculated as in Eq. (3), D is a predefined splitting depth which is set to 3 by default in the JEM. Then the MV for each sub-CU is derived.

$\begin{matrix} {M = {\max\mspace{11mu}\left\{ {4,{\min\mspace{11mu}\left\{ {\frac{M}{2^{D}},\ \frac{N}{2^{D}}} \right\}}} \right\}}} & {{Eq}.\mspace{14mu}(3)} \end{matrix}$

FIG. 18 shows an example of bilateral matching used in the Frame-Rate Up Conversion (FRUC) method. The bilateral matching is used to derive motion information of the current CU by finding the closest match between two blocks along the motion trajectory of the current CU (1800) in two different reference pictures (1810, 1811). Under the assumption of continuous motion trajectory, the motion vectors MV0 (1801) and MV1 (1802) pointing to the two reference blocks are proportional to the temporal distances, e.g., TD0 (1803) and TD1 (1804), between the current picture and the two reference pictures. In some embodiments, when the current picture 1800 is temporally between the two reference pictures (1810, 1811) and the temporal distance from the current picture to the two reference pictures is the same, the bilateral matching becomes mirror based bi-directional MV.

FIG. 19 shows an example of template matching used in the Frame-Rate Up Conversion (FRUC) method. Template matching can be used to derive motion information of the current CU 1900 by finding the closest match between a template (e.g., top and/or left neighboring blocks of the current CU) in the current picture and a block (e.g., same size to the template) in a reference picture 1910. Except the aforementioned FRUC merge mode, the template matching can also be applied to AMVP mode. In both JEM and HEVC, AMVP has two candidates. With the template matching method, a new candidate can be derived. If the newly derived candidate by template matching is different to the first existing AMVP candidate, it is inserted at the very beginning of the AMVP candidate list and then the list size is set to two (e.g., by removing the second existing AMVP candidate). When applied to AMVP mode, only CU level search is applied.

The MV candidate set at CU level can include the following: (1) original AMVP candidates if the current CU is in AMVP mode, (2) all merge candidates, (3) several MVs in the interpolated MV field (described later), and top and left neighboring motion vectors.

When using bilateral matching, each valid MV of a merge candidate can be used as an input to generate a MV pair with the assumption of bilateral matching. For example, one valid MV of a merge candidate is (MVa, ref_(a)) at reference list A. Then the reference picture ref_(b) of its paired bilateral MV is found in the other reference list B so that ref_(a) and ref_(b) are temporally at different sides of the current picture. If such a ref_(b) is not available in reference list B, ref_(b) is determined as a reference which is different from ref_(a) and its temporal distance to the current picture is the minimal one in list B. After ref_(b) is determined, MVb is derived by scaling MVa based on the temporal distance between the current picture and ref_(a), ref_(b).

In some implementations, four MVs from the interpolated MV field can also be added to the CU level candidate list. More specifically, the interpolated MVs at the position (0, 0), (W/2, 0), (0, H/2) and (W/2, H/2) of the current CU are added. When FRUC is applied in AMVP mode, the original AMVP candidates are also added to CU level MV candidate set. In some implementations, at the CU level, 15 MVs for AMVP CUs and 13 MVs for merge CUs can be added to the candidate list.

The MV candidate set at sub-CU level includes an MV determined from a CU-level search, (2) top, left, top-left and top-right neighboring MVs, (3) scaled versions of collocated MVs from reference pictures, (4) one or more ATMVP candidates (e.g., up to four), and (5) one or more STMVP candidates (e.g., up to four). The scaled MVs from reference pictures are derived as follows. The reference pictures in both lists are traversed. The MVs at a collocated position of the sub-CU in a reference picture are scaled to the reference of the starting CU-level MV. ATMVP and STMVP candidates can be the four first ones. At the sub-CU level, one or more MVs (e.g., up to 17) are added to the candidate list.

Generation of an interpolated MV field. Before coding a frame, interpolated motion field is generated for the whole picture based on unilateral ME. Then the motion field may be used later as CU level or sub-CU level MV candidates.

In some embodiments, the motion field of each reference pictures in both reference lists is traversed at 4×4 block level. FIG. 20 shows an example of unilateral Motion Estimation (ME) 2000 in the FRUC method. For each 4×4 block, if the motion associated to the block passing through a 4×4 block in the current picture and the block has not been assigned any interpolated motion, the motion of the reference block is scaled to the current picture according to the temporal distance TD0 and TD1 (the same way as that of MV scaling of TMVP in HEVC) and the scaled motion is assigned to the block in the current frame. If no scaled MV is assigned to a 4×4 block, the block's motion is marked as unavailable in the interpolated motion field.

Interpolation and matching cost. When a motion vector points to a fractional sample position, motion compensated interpolation is needed. To reduce complexity, bi-linear interpolation instead of regular 8-tap HEVC interpolation can be used for both bilateral matching and template matching.

The calculation of matching cost is a bit different at different steps. When selecting the candidate from the candidate set at the CU level, the matching cost can be the absolute sum difference (SAD) of bilateral matching or template matching. After the starting MV is determined, the matching cost C of bilateral matching at sub-CU level search is calculated as follows:

$\begin{matrix} {C = {{SAD} + {w \cdot \left( \left| {{MV}_{x} - {MV_{x}^{s}}} \middle| {+ \left| {{MV_{y}} - {MV_{y}^{s}}} \right|} \right. \right)}}} & {{Eq}.\mspace{14mu}(4)} \end{matrix}$

Here, w is a weighting factor. In some embodiments, w can be empirically set to 4. MV and MV^(s) indicate the current MV and the starting MV, respectively. SAD may still be used as the matching cost of template matching at sub-CU level search.

In FRUC mode, MV is derived by using luma samples only. The derived motion will be used for both luma and chroma for MC inter prediction. After MV is decided, final MC is performed using 8-taps interpolation filter for luma and 4-taps interpolation filter for chroma.

MV refinement is a pattern based MV search with the criterion of bilateral matching cost or template matching cost. In the JEM, two search patterns are supported—an unrestricted center-biased diamond search (UCBDS) and an adaptive cross search for MV refinement at the CU level and sub-CU level, respectively. For both CU and sub-CU level MV refinement, the MV is directly searched at quarter luma sample MV accuracy, and this is followed by one-eighth luma sample MV refinement. The search range of MV refinement for the CU and sub-CU step are set equal to 8 luma samples.

In the bilateral matching merge mode, bi-prediction is applied because the motion information of a CU is derived based on the closest match between two blocks along the motion trajectory of the current CU in two different reference pictures. In the template matching merge mode, the encoder can choose among uni-prediction from list0, uni-prediction from list1, or bi-prediction for a CU. The selection ca be based on a template matching cost as follows:

If costBi<=factor*min (cost0, cost1)

-   -   bi-prediction is used;     -   Otherwise, if cost0<=cost1         -   uni-prediction from list0 is used;     -   Otherwise,         -   uni-prediction from list1 is used;

Here, cost0 is the SAD of list0 template matching, cost1 is the SAD of list1 template matching and costBi is the SAD of bi-prediction template matching. For example, when the value of factor is equal to 1.25, it means that the selection process is biased toward bi-prediction. The inter prediction direction selection can be applied to the CU-level template matching process.

2.8 Examples of Generalized Bi-Prediction Improvement (GBi)

Generalized Bi-prediction improvement (GBi) proposed in JVET-L0646 is adopted into VTM-3.0. GBi applies unequal weights to predictors from L0 and L1 in bi-prediction mode. In inter prediction mode, multiple weight pairs including the equal weight pair (½, ½) are evaluated based on rate-distortion optimization (RDO), and the GBi index of the selected weight pair is signaled to the decoder. In merge mode, the GBi index is inherited from a neighboring CU. The predictor generation formula is shown as in Equation (5).

P _(GBi)=(w0×P _(L0) +w1×P _(L1)+RoundingOffset)>>shiftNum_(GBi)  Eq. (5)

Herein, P_(GBi) is the final predictor of GBi, w₀ and w₁ are the selected GBi weights applied to predictors (P_(L0) and P_(L1)) of list 0 (L0) and list 1 (L1), respectively. RoundingOffset_(GBi) and shiftNum_(GBi) are used to normalize the final predictor in GBi. The supported w_(l) weight set is {−¼, ⅜, ½, ⅝, 5/4}, in which the five weights correspond to one equal weight pair and four unequal weight pairs. The blending gain, i.e., sum of w₁ and w₀, is fixed to 1.0. Therefore, the corresponding w₀ weight set is {5/4, ⅝, ½, ⅜, −¼}. The weight pair selection is at CU-level.

For non-low delay pictures, the weight set size is reduced from five to three, where the w₁ weight set is {⅜, ½, ⅝} and the w₀ weight set is {⅝, ½, ⅜}. The weight set size reduction for non-low delay pictures is applied to the BMS2.1 GBi and all the GBi tests in this contribution.

2.8.1 GBi Encoder Bug Fix

To reduce the GBi encoding time, in current encoder design, the encoder will store uni-prediction motion vectors estimated from GBi weight equal to 4/8, and reuse them for uni-prediction search of other GBi weights. This fast encoding method is applied to both translation motion model and affine motion model. In VTM2.0, 6-parameter affine model was adopted together with 4-parameter affine model. The BMS2.1 encoder does not differentiate 4-parameter affine model and 6-parameter affine model when it stores the uni-prediction affine MVs when GBi weight is equal to 4/8. Consequently, 4-parameter affine MVs may be overwritten by 6-parameter affine MVs after the encoding with GBi weight 4/8. The stored 6-parameter affine MVs may be used for 4-parameter affine ME for other GBi weights, or the stored 4-parameter affine MVs may be used for 6-parameter affine ME. The proposed GBi encoder bug fix is to separate the 4-parameter and 6-parameter affine MVs storage. The encoder stores those affine MVs based on affine model type when GBi weight is equal to 4/8, and reuse the corresponding affine MVs based on the affine model type for other GBi weights.

2.8.2 GBi Encoder Speed Up

In this existing implementation, five encoder speed-up methods are proposed to reduce the encoding time when GBi is enabled.

(1) Skipping Affine Motion Estimation for Some GBi Weights Conditionally

In BMS2.1, affine ME including 4-parameter and 6-parameter affine ME is performed for all GBi weights. We propose to skip affine ME for those unequal GBi weights (weights unequal to 4/8) conditionally. Specifically, affine ME will be performed for other GBi weights if and only if the affine mode is selected as the current best mode and it is not affine merge mode after evaluating the GBi weight of 4/8. If current picture is non-low-delay picture, the bi-prediction ME for translation model will be skipped for unequal GBi weights when affine ME is performed. If affine mode is not selected as the current best mode or if affine merge is selected as the current best mode, affine ME will be skipped for all other GBi weights.

(2) Reducing the Number of Weights for RD Cost Checking for Low-Delay Pictures in the Encoding for 1-Pel and 4-Pel MVD Precision

For low-delay pictures, there are five weights for RD cost checking for all MVD precisions including ¼-pel, 1-pel and 4-pel. The encoder will check RD cost for ¼-pel MVD precision first. We propose to skip a portion of GBi weights for RD cost checking for 1-pel and 4-pel MVD precisions. We order those unequal weights according to their RD cost in ¼-pel MVD precision. Only the first two weights with the smallest RD costs, together with GBi weight 4/8, will be evaluated during the encoding in 1-pel and 4-pel MVD precisions. Therefore, three weights at most will be evaluated for 1-pel and 4-pel MVD precisions for low delay pictures.

(3) Conditionally Skipping Bi-Prediction Search when the L0 and L1 Reference Pictures are the Same

For some pictures in RA, the same picture may occur in both reference picture lists (list-0 and list-1). For example, for random access coding configuration in CTC, the reference picture structure for the first group of pictures (GOP) is listed as follows.

-   -   POC: 16, TL:0, [L0: 0] [L1: 0]     -   POC: 8, TL:1, [L0: 0 16] [L1: 16 0]     -   POC: 4, TL:2, [L0: 0 8] [L1: 8 16]     -   POC: 2, TL:3, [L0: 0 4] [L1: 4 8]     -   POC: 1, TL:4, [L0: 0 2] [L1: 2 4]     -   POC: 3, TL:4, [L0: 20] [L1: 48]     -   POC: 6, TL:3, [L0: 40] [L1: 816]     -   POC: 5, TL:4, [L0: 40] [L1: 68]     -   POC: 7, TL:4, [L0: 64] [L1: 816]     -   POC: 12, TL:2, [L0: 80] [L1: 168]     -   POC: 10, TL:3, [L0: 80] [L1: 1216]     -   POC: 9, TL:4, [L0: 80] [L1: 1012]     -   POC: 11, TL:4, [L0: 108] [L1: 1216]     -   POC: 14, TL:3, [L0: 12 8] [L1: 12 16]     -   POC: 13, TL:4, [L0: 128] [L1: 1416]     -   POC: 15, TL:4, [L0: 14 12] [L1: 16 14]

Note that pictures 16, 8, 4, 2, 1, 12, 14 and 15 have the same reference picture(s) in both lists. For bi-prediction for these pictures, it is possible that the L0 and L1 reference pictures are the same. We propose that the encoder skips bi-prediction ME for unequal GBi weights when 1) two reference pictures in bi-prediction are the same and 2) temporal layer is greater than 1 and 3) the MVD precision is ¼-pel. For affine bi-prediction ME, this fast skipping method is only applied to 4-parameter affine ME.

(4) Skipping RD Cost Checking for Unequal GBi Weight Based on Temporal Layer and the POC Distance Between Reference Picture and Current Picture

We propose to skip those RD cost evaluations for those unequal GBi weights when the temporal layer is equal to 4 (highest temporal layer in RA) or the POC distance between reference picture (either list-0 or list-1) and current picture is equal to 1 and coding QP is greater than 32.

(5) Changing Floating-Point Calculation to Fixed-Point Calculation for Unequal GBi Weight During ME

For existing bi-prediction search, the encoder will fix the MV of one list and refine MV in another list. The target is modified before ME to reduce the computation complexity. For example, if the MV of list-1 is fixed and encoder is to refine MV of list-0, the target for list-0 MV refinement is modified with Equation (6). O is original signal and P₁ is the prediction signal of list-1. w is GBi weight for list-1.

$\begin{matrix} {T = {\left( {\left( {O ⪡ 3} \right) - {w*P_{1}}} \right)*\left( {1/\left( {8 - w} \right)} \right)}} & {{Eq}.\mspace{14mu}(6)} \end{matrix}$

Herein, the term (1/(8−w)) is stored in floating point precision, which increases computation complexity. We propose to change Equation (6) to fixed-point as in Equation (7).

T=(O*a ₁ −P ₁ *a ₂+round)>>N  Eq. (7)

where a₁ and a₂ are scaling factors and they are calculated as:

γ = (1 ⪡ N)/(8 − w); a₁ = γ ⪡ 3; a₂ = γ * w; round = 1 ⪡ (N − 1)

2.8.3 CU Size Constraint for GBi

In this method, GBi is disabled for small CUs. In inter prediction mode, if bi-prediction is used and the CU area is smaller than 128 luma samples, GBi is disabled without any signaling.

2.9 Examples of Bi-Directional Optical Flow (BDOF or BIO) 2.9.1 Overview of BDOF

In BIO, motion compensation is first performed to generate the first predictions (in each prediction direction) of the current block. The first predictions are used to derive the spatial gradient, the temporal gradient and the optical flow of each sub-block or pixel within the block, which are then used to generate the second prediction, e.g., the final prediction of the sub-block or pixel. The details are described as follows.

The bi-directional optical flow (BIO) method is a sample-wise motion refinement performed on top of block-wise motion compensation for bi-prediction. In some implementations, the sample-level motion refinement does not use signaling.

Let I^((k)) be the luma value from reference k (k=0, 1) after block motion compensation, and denote ∂I^((k))/∂x and ∂I^((k))/∂y as the horizontal and vertical components of the I^((k)) gradient, respectively. Assuming the optical flow is valid, the motion vector field (v_(x), v_(y)) is given by:

$\begin{matrix} {{{{\partial I^{(k)}}/{\partial t}} + {v_{x}{{\partial I^{(k)}}/{\partial x}}} + {v_{y}{{\partial I^{(k)}}/{\partial y}}}} = 0.} & {{Eq}.\mspace{14mu}(8)} \end{matrix}$

Combining this optical flow equation with Hermite interpolation for the motion trajectory of each sample results in a unique third-order polynomial that matches both the function values I^((k)) and derivatives ∂I^((k))/∂x and ∂I^((k))/∂y at the ends. The value of this polynomial at t=0 is the BIO prediction:

pred_(BIO)=½·(I ⁽⁰⁾ +I ⁽¹⁾ +v _(x)/2·(τ₁ ∂I ⁽¹⁾ /∂x−τ ₀ ∂I ⁽⁰⁾ /∂x)+v _(y)/2·(τ₁ ∂I ⁽¹⁾ /∂y−τ ₀ ∂I ⁽⁰⁾ /∂y)).  Eq. (9)

FIG. 24 shows an example optical flow trajectory in the Bi-directional Optical flow (BIO) method. Here, τ₀ and τ₁ denote the distances to the reference frames. Distances τ₀ and τ₁ are calculated based on POC for Ref₀ and Ref₁: τ₀=POC(current)−POC(Ref₀), τ₁=POC(Ref₁)−POC(current). If both predictions come from the same time direction (either both from the past or both from the future) then the signs are different (e.g., τ₀·τ₁<0). In this case, BIO is applied if the prediction is not from the same time moment (e.g., τ₀≠τ₁). Both referenced regions have non-zero motion (e.g., MVx₀,MVy₀,MVx₁,MVy₁≠0) and the block motion vectors are proportional to the time distance (e.g., MVx₀/MVx₁=MVy₀/MVy₁=−τ₀/τ₁).

The motion vector field (v_(x), v_(y)) is determined by minimizing the difference Δ between values in points A and B. FIGS. 9A-9B show an example of intersection of motion trajectory and reference frame planes. Model uses only first linear term of a local Taylor expansion for Δ:

Δ=(I ⁽⁰⁾ −I ⁽¹⁾ ₀ +v _(x)(τ₁ ∂I ⁽¹⁾ /∂x+τ ₀ ∂I ⁽⁰⁾ /∂x)+v _(y)(τ₁ ∂I ⁽¹⁾ /∂y+τ ₀ I ⁽⁰⁾ /∂y))  Eq. (10)

All values in the above equation depend on the sample location, denoted as (i′,j′). Assuming the motion is consistent in the local surrounding area, Δ can be minimized inside the (2M+1)×(2M+1) square window Ω centered on the currently predicted point (i,j), where M is equal to 2:

$\begin{matrix} {\left( {v_{x},v_{y}} \right) = {\underset{v_{x},v_{y}}{\arg\mspace{11mu}\min}{\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}{\Delta^{2}\left\lbrack {i^{\prime},j^{\prime}} \right\rbrack}}}} & {{Eq}.\mspace{14mu}(11)} \end{matrix}$

For this optimization problem, the JEM uses a simplified approach making first a minimization in the vertical direction and then in the horizontal direction. This results in the following:

$\begin{matrix} {\mspace{76mu}{v_{x} = {\left( {s_{1} + r} \right) > {{m?\;{clip}}\; 3\mspace{11mu}\left( {{- {thBIO}},{thBIO},{- \frac{s_{3}}{\left( {s_{1} + r} \right)}}} \right)\text{:}0}}}} & {{Eq}.\mspace{14mu}(12)} \\ {{v_{y} = {\left( {s_{5} + r} \right) > {{m?\;{clip}}\; 3\mspace{11mu}\left( {{- {thBIO}},{thBIO},{- \frac{s_{6} - {v_{x}{s_{2}/2}}}{\left( {s_{5} + r} \right)}}} \right)\text{:}0}}}\mspace{20mu}{{where},}} & {{Eq}.\mspace{14mu}(13)} \\ {{{s_{1} = {\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial x}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial x}}}} \right)^{2}}};{s_{3} = {\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}{\left( {I^{(1)} - I^{(0)}} \right)\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial x}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial x}}}} \right)}}};}{{s_{2} = {\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}{\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial x}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial x}}}} \right)\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial y}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial y}}}} \right)}}};}{{s_{5} = {\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial y}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial y}}}} \right)^{2}}};{s_{6} = {\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}{\left( {I^{(1)} - I^{(0)}} \right)\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial y}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial y}}}} \right)}}}}} & {{Eq}.\mspace{14mu}(14)} \end{matrix}$

In order to avoid division by zero or a very small value, regularization parameters r and m can be introduced in Eq. (12) and Eq. (13), where:

$\begin{matrix} {r = {500 \cdot 4^{d - 8}}} & {{Eq}.\mspace{14mu}(15)} \\ {m = {700 \cdot 4^{d - 8}}} & {{Eq}.\mspace{14mu}(16)} \end{matrix}$

Here, d is bit depth of the video samples.

In order to keep the memory access for BIO the same as for regular bi-predictive motion compensation, all prediction and gradients values, I^((k)), ∂I^((k))/∂x, ∂I^((k))/∂y, are calculated for positions inside the current block. FIG. 22A shows an example of access positions outside of a block 2200. As shown in FIG. 22A, in Eq. (12), (2M+1)×(2M+1) square window Ω centered in currently predicted point on a boundary of predicted block needs to accesses positions outside of the block. In the JEM, values of I^((k)), ∂I^((k))/∂x, ∂I^((k))/∂y outside of the block are set to be equal to the nearest available value inside the block. For example, this can be implemented as a padding area 2201, as shown in FIG. 22B.

With BIO, it is possible that the motion field can be refined for each sample. To reduce the computational complexity, a block-based design of BIO is used in the JEM. The motion refinement can be calculated based on a 4×4 block. In the block-based BIO, the values of s_(n) in Eq. (12) of all samples in a 4×4 block can be aggregated, and then the aggregated values of s_(n) in are used to derived BIO motion vectors offset for the 4×4 block. More specifically, the following formula can used for block-based BIO derivation:

$\begin{matrix} {{{s_{1,b_{k}} = {\sum\limits_{{({x,y})} \in b_{k}}^{\;}{\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in {\Omega{({x,y})}}}^{\;}\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial x}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial x}}}} \right)^{2}}}};{s_{3,b_{k}} = {\sum\limits_{{({x,y})} \in b_{k}}^{\;}{\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}{\left( {I^{(1)} - I^{(0)}} \right)\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial x}}} + {\tau_{0}{{\partial I^{(1)}}/{\partial x}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial x}}}} \right)}}}};}{{s_{2,b_{k}} = {\sum\limits_{{({x,y})} \in b_{k}}^{\;}{\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}{\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial x}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial x}}}} \right)\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial y}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial y}}}} \right)}}}};}{{s_{5,b_{k}}{\sum\limits_{{({x,y})} \in b_{k}}^{\;}{\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial y}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial y}}}} \right)^{2}}}};{s_{6,b_{k}} = {\sum\limits_{{({x,y})} \in b_{k}}^{\;}{\sum\limits_{{\lbrack{i^{\prime},j}\rbrack} \in \Omega}^{\;}{\left( {I^{(1)} - I^{(0)}} \right)\left( {{\tau_{1}{{\partial I^{(1)}}/{\partial y}}} + {\tau_{0}{{\partial I^{(0)}}/{\partial y}}}} \right)}}}}}} & {{Eq}.\mspace{14mu}(17)} \end{matrix}$

Here, b_(k) denotes the set of samples belonging to the k-th 4×4 block of the predicted block. s_(n) in Eq. (12) and Eq. (13) are replaced by ((s_(n),b_(k))>>4) to derive the associated motion vector offsets.

In some scenarios, MV regiment of BIO may be unreliable due to noise or irregular motion. Therefore, in BIO, the magnitude of MV regiment is clipped to a threshold value. The threshold value is determined based on whether the reference pictures of the current picture are all from one direction. For example, if all the reference pictures of the current picture are from one direction, the value of the threshold is set to 12×2^(14-d); otherwise, it is set to 12×2^(13-d).

Gradients for BIO can be calculated at the same time with motion compensation interpolation using operations consistent with HEVC motion compensation process (e.g., 2D separable Finite Impulse Response (FIR)). In some embodiments, the input for the 2D separable FIR is the same reference frame sample as for motion compensation process and fractional position (fracX,fracY) according to the fractional part of block motion vector. For horizontal gradient ∂I/∂x, a signal is first interpolated vertically using BIOfilterS corresponding to the fractional position fracY with de-scaling shift d-8. Gradient filter BIOfilterG is then applied in horizontal direction corresponding to the fractional position fracX with de-scaling shift by 18-d. For vertical gradient ∂I/∂y, a gradient filter is applied vertically using BIOfilterG corresponding to the fractional position fracY with de-scaling shift d-8. The signal displacement is then performed using BIOfilterS in horizontal direction corresponding to the fractional position fracX with de-scaling shift by 18-d. The length of interpolation filter for gradients calculation BIOfilterG and signal displacement BIOfilterF can be shorter (e.g., 6-tap) in order to maintain reasonable complexity. Table 1 shows example filters that can be used for gradients calculation of different fractional positions of block motion vector in BIO. Table 2 shows example interpolation filters that can be used for prediction signal generation in BIO.

TABLE 1 Exemplary filters for gradient calculations in BIO Fractional pel position Interpolation filter for gradient(BIOfilterG) 0 {8, −39, −3, 46, −17, 5} 1/16 {8, −32, −13, 50, −18, 5} ⅛ {7, −27, −20, 54, −19, 5} 3/16 {6, −21, −29, 57, −18, 5} ¼ {4, −17, −36, 60, −15, 4} 5/16 {3, −9, −44, 61, −15, 4} ⅜ {1, −4, −48, 61, −13, 3} 7/16 {0, 1, −54, 60, −9, 2} ½ {−1, 4, −57, 57, −4, 1}

TABLE 2 Exemplary interpolation filters for prediction signal generation in BIO Fractional pel position Interpolation filter for prediction signal(BIOfilterS) 0 {0, 0, 64, 0, 0, 0} 1/16 {1, −3, 64, 4, −2, 0} ⅛ {1, −6, 62, 9, −3, 1} 3/16 {2, −8, 60, 14, −5, 1} ¼ {2, −9, 57, 19, −7, 2} 5/16 {3, −10, 53, 24, −8, 2} ⅜ {3, −11, 50, 29, −9, 2} 7/16 {3, −11, 44, 35, −10, 3} ½ {3, −10, 35, 44, −11, 3}

In the JEM, BIO can be applied to all bi-predicted blocks when the two predictions are from different reference pictures. When Local Illumination Compensation (LIC) is enabled for a CU, BIO can be disabled.

In some embodiments, OBMC is applied for a block after normal MC process. To reduce the computational complexity, BIO may not be applied during the OBMC process. This means that BIO is applied in the MC process for a block when using its own MV and is not applied in the MC process when the MV of a neighboring block is used during the OBMC process.

2.9.2 Examples of BIO in VTM-3.0 as Proposed in JVET-L0256

Step 1: Judge whether BIO is applicable (W/H are width/height of current block)

BIO is not applicable if

-   -   Current video block is affine coded or ATTMVP coded     -   (iPOC−iPOC₀)×(iPOC−iPOC₁)≥0     -   H==4 or (W==4 and H==8)     -   with Weighted Prediction     -   GBi weights are not (1,1)

BIO is not used if total SAD between the two reference blocks (denoted as R₀ and R₁) is smaller than a threshold, wherein

${SAD} = {\sum\limits_{({x,y})}{{{R_{0}\left( {x,y} \right)} - {R_{1}\left( {x,y} \right)}}}}$

Step 2: Data Preparation

For a W×H block, (W+2)×(H+2) samples are interpolated.

The inner W×H samples are interpolated with the 8-tap interpolation filter as in normal motion compensation.

The four side outer lines of samples (black circles in FIG. 23) are interpolated with the bi-linear filter.

For each position, gradients are calculated on the two reference blocks (R₀ and R₁).

Gx0(x,y)=(R0(x+1,y)−R0(x−1,y))>>4

Gy0(x,y)=(R0(x,y+1)−R0(x,y−1))>>4

Gx1(x,y)=(R1(x+1,y)−R1(x−1,y))>>4

Gy1(x,y)=(R1(x,y+1)−R1(x,y−1))>>4

For each position, internal values are calculated as:

T1=(R0(x,y)>>6)−(R1(x,y)>>6),T2=(Gx0(x,y)+Gx1(x,y))>>3,T3=(Gy0(x,y)+Gy1(x,y))>>3; and

B1(x,y)=T2*T2,B2(x,y)=T2*T3,B3(x,y)=−T1*T2,B5(x,y)=T3*T3,B6(x,y)=−T1*T3

Step 3: Calculate Prediction for Each Block

BIO is skipped for a 4×4 block if SAD between the two 4×4 reference blocks is smaller than a threshold.

Calculate Vx and Vy.

Calculate the final prediction for each position in the 4×4 block:

b(x,y)(Vx(Gx ⁰(x,y)−Gx ¹(x,y))+Vy(Gy ⁰(x,y)−Gy ¹(x,y))+1)>>1

P(x,y)(R ⁰(x,y)+R ¹(x,y)+b(x,y)+offset)>>shift

Herein, b(x,y) is known as a correction item.

2.9.3 BIO in VTM-4.0

JVET-M0063, which proposed to round the results of calculation in BDOF depending on bit-depth was adopted into VTM-4.0.

JVET-M0487 was adopted into VTM-4.0, which removed the bi-linear filtering and fetched the nearest integer pixel of the reference block to pad the four side outer lines of samples (black circles in FIG. 23).

The working draft related to BIO in VTM-4.0 are shown as below (from JVET-M1001)

2.9.4 Fractional Sample Interpolation Process General

Inputs to this process are:

-   -   a luma location (xSb, ySb) specifying the top-left sample of the         current coding subblock relative to the top-left luma sample of         the current picture,     -   a variable sbWidth specifying the width of the current coding         subblock,     -   a variable sbHeight specifying the height of the current coding         subblock,     -   a motion vector offset mvOffset,     -   a refined motion vector refMvLX,     -   the selected reference picture sample array refPicLX,     -   the bidirectional optical flow flag bdofFlag,     -   a variable cIdx specifying the colour component index of the         current block.         Outputs of this process are:     -   an (sbWidth+bdofOffset)×(sbHeight+bdofOffset) array         predSamplesLX of prediction sample values.         The bidirectional optical flow boundary offset bdofOffset is         derived as follows:

bdofOffset=bdofFlag ? 2:0  (8-811)

-   -   If cIdx is equal to 0, the following applies:         -   Let (xIntL, yIntL) be a luma location given in full-sample             units and (xFracL, yFracL) be an offset given in 1/16-sample             units. These variables are used only in this clause for             specifying fractional-sample locations inside the reference             sample arrays refPicLX.         -   For each luma sample location (x_(L)=0 . . .             sbWidth−1+bdofOffset, y_(L)=0 . . . sbHeight−1+bdofOffset)             inside the prediction luma sample array predSamplesLX, the             corresponding prediction luma sample value             predSamplesLX[x_(L)][y_(L)] is derived as follows:         -   The variables xInt_(L), yInt_(L), xFrac_(L) and yFrac_(L)             are derived as follows:

xInt_(L) =xSb+(refMvLX[0]>>4)+x _(L)   (8-812)

yInt_(L) =ySb+(refMvLX[1]>>4)+y _(L)   (8-813)

xFrac_(L)=refMvLX[0] & 15  (8-814)

yFrac_(L)=refMvLX[1] & 15  (8-815)

-   -   If bdofFlag is equal to TRUE and one or more of the following         conditions are true, the prediction luma sample value         predSamplesLX[x_(L)][y_(L)] is derived by invoking the luma         integer sample fetching process as specified in clause 8.5.7.3.3         with (xInt_(L), yInt_(L)), (xFrac_(L), yFrac_(L)) and refPicLX         as inputs:         -   bdofFlag is equal to TRUE.         -   x_(L) is equal to 0.         -   x_(L) is equal to sbWidth+1.         -   y_(L) is equal to 0.         -   y_(L) is equal to sbHeight+1.     -   Otherwise, the following applies:         -   The motion vector mvLX is set equal to (refMvLX−mvOffset).         -   The prediction luma sample value predSamplesLX[xL][yL] is             derived by invoking the luma sample 8-tap interpolation             filtering process as specified in clause 8.5.7.3.2 with             (xIntL, yIntL), (xFracL, yFracL), refPicLX, and padVal as             inputs.     -   . . .

Luma Integer Sample Fetching Process

Inputs to this process are:

-   -   a luma location in full-sample units (xInt_(L), yInt_(L)),     -   the luma reference sample array refPicLX_(L),         Output of this process is a predicted luma sample value         predSampleLX_(L)         The variable shift is set equal to Max(2, 14−BitDepth_(Y)).         The variable picW is set equal to pic_width_in_luma_samples and         the variable picH is set equal to pic_height_in_luma_samples.         The luma locations in full-sample units (xInt, yInt) are derived         as follows:

xInt=Clip3(0,picW−1,sps_ref_wraparound_enabled_flag ? ClipH((sps_ref_wraparound_offset_minus1+1)*MinCbSizeY,picW,xInt_(L)):xInt_(L))  (8-838)

yInt=Clip3(0,picH−1,yIntL)  (8-839)

The predicted luma sample value predSampleLX_(L) is derived as follows:

predSampleLX _(L)=refPicLX _(L)[xInt][yInt]>>shift3   (8-840)

Bidirectional Optical Flow Prediction Process

Inputs to this process are:

-   -   two variables nCbW and nCbH specifying the width and the height         of the current coding block,     -   two (nCbW+2)×(nCbH+2) luma prediction sample arrays         predSamplesL0 and predSamplesL1,     -   the prediction list utilization flags predFlagL0 and predFlagL1,     -   the reference indices refIdxL0 and refIdxL1,     -   the bidirectional optical flow utilization flags         bdofUtilizationFlag[xIdx][yIdx] with xIdx=0 . . . (nCbW>>2)−1,         yIdx=0 . . . (nCbH>>2)−1.         Output of this process is the (nCbW)×(nCbH) array pbSamples of         luma prediction sample values.         Variables bitDepth, shift1, shift2, shift3, shift4, offset4, and         mvRefineThres are derived as follows:     -   The variable bitDepth is set equal to BitDepth_(Y).     -   The variable shift1 is set to equal to Max(2, 14−bitDepth).     -   The variable shift2 is set to equal to Max(8, bitDepth−4).     -   The variable shift3 is set to equal to Max(5, bitDepth−7).     -   The variable shift4 is set equal to Max(3, 15−bitDepth) and the         variable offset4 is set equal to 1<<(shift4−1).     -   The variable mvRefineThres is set equal to Max(2,         1<<(13−bitDepth)).         For xIdx=0 . . . (nCbW>>2)−1 and yIdx=0 . . . (nCbH>>2)−1, the         following applies:     -   The variable xSb is set equal to (xIdx<<2)+1 and ySb is set         equal to (yIdx<<2)+1.     -   If bdofUtilizationFlag[xSbIdx][yIdx] is equal to FALSE, for         x=xSb−1 . . . xSb+2, y=ySb−1 . . . ySb+2, the prediction sample         values of the current subblock are derived as follows:

pbSamples[x][y]=Clip3(0,(2^(bitDepth))−1,(predSamplesL0[x+1][y+1]+offset2+

predSamplesL1[x+1][y+1])>>shift2)  (8-852)

-   -   Otherwise (bdofUtilizationFlag[xSbIdx][yIdx] is equal to TRUE),         the prediction sample values of the current subblock are derived         as follows:         -   For x=xSb−1 . . . xSb+4, y=ySb−1 . . . ySb+4, the following             ordered steps apply:         -   1. The locations (h_(x), v_(y)) for each of the             corresponding sample locations (x, y) inside the prediction             sample arrays are derived as follows:

$\begin{matrix} {h_{x} = {{Clip}\; 3\left( {1,{nCbW},x} \right)}} & \left( {8\text{-}853} \right) \\ {v_{y} = {{Clip}\; 3\left( {1,{nCbH},y} \right)}} & \left( {8\text{-}854} \right) \end{matrix}$

-   -   -   2. The variables gradientHL0[x][y], gradientVL0[x][y],             gradientHL1[x][y] and gradientVL1[x][y] are derived as             follows:

gradientHL0[x][y]=(predSamplesL0[h _(x)+1][v _(y)]−predSampleL0[h _(x)−1][v _(y)])>>shift1   (8-855)

gradientVL0[x][y]=(predSampleL0[h _(x)][v _(y)+1]−predSampleL0[h _(x)][v _(y)−1])>>shift1   (8-856)

gradientHL1[x][y]=(predSamplesL1[h _(x)+1][v _(y)]−predSampleL1[h _(x)−1][v _(y)])>>shift1   (8-857)

gradientVL1[x][y]=(predSampleL1[h _(x)][v _(y)+1]−predSampleL1[h _(x)][v _(y)−1])>>shift1   (8-858)

-   -   -   3. The variables temp[x][y], tempH[x][y] and tempV[x][y] are             derived as follows:

diff[x][y]=(predSamplesL0[h _(x)][v _(y)]>>shift2)−(predSamplesL1[h _(x)][v _(y)]>>shift2)   (8-859)

tempH[x][y]=(gradientHL0[x][y]+gradientHL1[x][y])>>shift3  (8-860)

tempV[x][y]=(gradientVL0[x][y]+gradientVL1[x][y])>>shift3  (8-861)

-   -   The variables sGx2, sGy2, sGxGy, sGxdI and sGydI are derived as         follows:

sGx2=Σ_(i)Σ_(j)(tempH[xSb+i][ySb+j]*tempH[xSb+i][ySb+j]) with i,j=−1 . . . 4   (8-862)

sGy2=Σ_(i)Σ_(j)(tempV[xSb+i][ySb+j]*tempV[xSb+i][ySb+j]) with i,j=−1 . . . 4   (8-863)

sGxGy=Σ _(i)Σ_(j)(tempH[xSb+i][ySb+j]*tempV[xSb+i][ySb+j]) with i,j−1 . . . 4   (8-864)

sGxdI=Σ _(i)Σ_(j)(−tempH[xSb+i][ySb+j]*diff[xSb+i][ySb+j]) with i,j=−1 . . . 4   (8-865)

sGydI=Σ _(i)Σ_(j)(−tempV[xSb+i][ySb+j]*diff[xSb+i][ySb+j]) with i,j=−1 . . . 4   (8-866)

-   -   The horizontal and vertical motion offset of the current         subblock are derived as:

v _(x) =sGx2>0 ? Clip3(−mvRefineThres,mvRefineThres,−(sGxdI<<3)>>Floor(Log 2(sGx2))):0  (8-867)

v _(y) =sGy2>0 ? Clip3(−mvRefineThres,mvRefineThres,((sGydI<<3)−((v _(x) *sGxGy _(m))<<12+v _(x) *sGxGy _(s))>>1)>>Floor(Log 2(sGx2))):0  (8-868)

-   -   For x=xSb−1 . . . xSb+2, y=ySb−1 . . . ySb+2, the prediction         sample values of the current sub-block are derived as follows:

bdofOffset=Round((v _(x)*(gradientHL1[x+1][y+1]−gradientHL0[x+1][y+1]))>>1)+Round((v _(y)*(gradientVL1[x+1][y+1]−gradientVL0[x+1][y+1]))>>1)  (8-869)

-   -   -   [Ed. (JC): Round( ) operation is defined for float input.             The Round( ) operation seems redundant here since the input             is an integer value. To be confirmed by the proponent]

pbSamples[x][y]=Clip3(0,(2^(bitDepth))−1,(predSamplesL0[x+1][y+1]+offset4+predSamplesL1[x+1][y+1]+bdofOffset)>>shift4)  (8-870)

2.10 Examples of Decoder-Side Motion Vector Refinement (DMVR)

In a bi-prediction operation, for the prediction of one block region, two prediction blocks, formed using a motion vector (MV) of list0 and a MV of list1, respectively, are combined to form a single prediction signal. In the decoder-side motion vector refinement (DMVR) method, the two motion vectors of the bi-prediction are further refined by a bilateral template matching process. The bilateral template matching applied in the decoder to perform a distortion-based search between a bilateral template and the reconstruction samples in the reference pictures in order to obtain a refined MV without transmission of additional motion information.

In DMVR, a bilateral template is generated as the weighted combination (i.e. average) of the two prediction blocks, from the initial MV0 of list0 and MV1 of list1, respectively, as shown in FIG. 24. The template matching operation consists of calculating cost measures between the generated template and the sample region (around the initial prediction block) in the reference picture. For each of the two reference pictures, the MV that yields the minimum template cost is considered as the updated MV of that list to replace the original one. In the JEM, nine MV candidates are searched for each list. The nine MV candidates include the original MV and 8 surrounding MVs with one luma sample offset to the original MV in either the horizontal or vertical direction, or both. Finally, the two new MVs, i.e., MV0′ and MV1′ as shown in FIG. 24, are used for generating the final bi-prediction results. A sum of absolute differences (SAD) is used as the cost measure. Please note that when calculating the cost of a prediction block generated by one surrounding MV, the rounded MV (to integer pel) is actually used to obtain the prediction block instead of the real MV.

DMVR is applied for the merge mode of bi-prediction with one MV from a reference picture in the past and another from a reference picture in the future, without the transmission of additional syntax elements. In the JEM, when LIC, affine motion, FRUC, or sub-CU merge candidate is enabled for a CU, DMVR is not applied.

2.11 JVET-N0236

This contribution proposes a method to refine the sub-block based affine motion compensated prediction with optical flow. After the sub-block based affine motion compensation is performed, prediction sample is refined by adding a difference derived by the optical flow equation, which is referred as prediction refinement with optical flow (PROF). The proposed method can achieve inter prediction in pixel level granularity without increasing the memory access bandwidth.

To achieve a finer granularity of motion compensation, this contribution proposes a method to refine the sub-block based affine motion compensated prediction with optical flow. After the sub-block based affine motion compensation is performed, luma prediction sample is refined by adding a difference derived by the optical flow equation. The proposed PROF (prediction refinement with optical flow) is described as following four steps.

Step 1) The sub-block-based affine motion compensation is performed to generate sub-block prediction I(i,j).

Step 2) The spatial gradients g_(x)(i,j) and g_(y)(i,j) of the sub-block prediction are calculated at each sample location using a 3-tap filter [−1, 0, 1].

g_(x)(i, j) = I(i + 1, j) − I(i − 1, j) g_(y)(i, j) = I(i, j + 1) − I(i, j − 1)

The sub-block prediction is extended by one pixel on each side for the gradient calculation. To reduce the memory bandwidth and complexity, the pixels on the extended borders are copied from the nearest integer pixel position in the reference picture. Therefore, additional interpolation for padding region is avoided.

Step 3) The luma prediction refinement (denoted ΔI) as is calculated by the optical flow equation.

ΔI(i,j)=g _(x)(i,j)*Δv _(x)(i,j)+g _(y)(i,j)*Δv _(y)(i,j)

where the delta MV (denoted as Δv(i,j)) is the difference between pixel MV computed for sample location (i,j), denoted by v(i,j), and the sub-block MV of the sub-block to which pixel (i,j) belongs, as shown in FIG. 25. Since the affine model parameters and the pixel location relative to the sub-block center are not changed from sub-block to sub-block, Δv(i,j) can be calculated for the first sub-block, and reused for other sub-blocks in the same CU. Let x and y be the horizontal and vertical offset from the pixel location to the center of the sub-block, Δv(x,y) can be derived by the following equation,

$\quad\left\{ \begin{matrix} {{\Delta\;{v_{x}\left( {x,y} \right)}} = {{c*x} + {d*y}}} \\ {{\Delta\;{v_{y}\left( {x,y} \right)}} = {{e*x} + {f*y}}} \end{matrix} \right.$

For 4-parameter affine model,

$\quad\left\{ \begin{matrix} {c = {f = \frac{v_{1x} - v_{0x}}{w}}} \\ {e = {{- d} = \frac{v_{1y} - v_{0y}}{w}}} \end{matrix} \right.$

For 6-parameter affine model

$\left\{ \begin{matrix} {c = \frac{v_{1x} - v_{0x}}{w}} \\ {d = \frac{v_{2x} - v_{0x}}{h}} \\ {e = \frac{v_{1y} - v_{0y}}{w}} \\ {f = \frac{v_{2y} - v_{0y}}{h}} \end{matrix} \right.$

where (v_(0x), v_(0y)), (v_(1x), v_(1y)), (v_(2x), v_(2y)) are the top-left, top-right and bottom-left control point motion vectors, w and h are the width and height of the CU.

Step 4) Finally, the luma prediction refinement is added to the sub-block prediction I(i,j). The final prediction I′ is generated as the following equation.

I′(i,j)=I(i,j)+ΔI(i,j)

Some Details in JVET-N0236 a) How to Derive the Gradients for PROF

-   -   In JVET-N0263, the gradients are calculated for each sub-block         (4×4 sub-block in VTM-4.0) for each reference list. For each         sub-block, the nearest integer samples of the reference block         are fetched to pad the four side outer lines of samples (black         circles in FIG. 23).     -   Suppose the MV for the current sub-block is (MVx, MVy). Then the         fractional part is calculated as (FracX, FracY)=(MVx&15,         MVy&15). The integer part is calculated as (IntX, IntY)=(MVx>>4,         MVy>>4). The offsets (OffsetX, OffsetY) are derived as:     -   OffsetX=FracX>7 ? 1: 0;     -   OffsetY=FracY>7 ? 1: 0;     -   Suppose the top-left coordinate of the current sub-block is         (xCur, yCur) and the dimensions of the current sub-block is W×H.     -   Then (xCor0, yCor0), (xCor1, yCor1), (xCor2, yCor2) and (xCor3,         yCor3) are calculated as     -   (xCor0, yCor0)=(xCur+IntX+OffsetX−1, yCur+IntY+OffsetY−1);     -   (xCor1, yCor1)=(xCur+IntX+OffsetX−1, yCur+IntY+OffsetY+H);     -   (xCor2, yCor2)=(xCur+IntX+OffsetX−1, yCur+IntY+OffsetY);     -   (xCor3, yCor3)=(xCur+IntX+OffsetX+W, yCur+IntY+OffsetY);     -   Suppose PredSample[x][y] with x=0 . . . W−1, y=0 . . . H−1         stores the prediction samples for the sub-block. Then the         padding samples are derived as     -   PredSample[x][−1]=(Ref(xCor0+x, yCor0)<<Shift0)—Rounding, for         x=−1 . . . W;     -   PredSample[x][H]=(Ref (xCor1+x, yCor1)<<Shift0)—Rounding, for         x=−1 . . . W;     -   PredSample[−1][y]=(Ref (xCor2, yCor2+y)<<Shift0)—Rounding, for         y=0 . . . H−1;     -   PredSample[W][y]=(Ref (xCor3, yCor3+y)<<Shift0)—Rounding, for         y=0 . . . H−1;     -   where Rec represents the reference picture. Rounding is an         integer, which is equal to 2¹³ in the exemplary PROF         implementation. Shift0=Max(2, (14−BitDepth));     -   PROF attempts to increase the precision of the gradients, unlike         BIO in VTM-4.0, where the gradients are output with the same         precision as input luma samples.     -   The gradients in PROF are calculated as below:

Shift1=Shift0-4.

gradientH[x][y]=(predSamples[x+1][y]−predSample[x−1][y])>>Shift1

gradientV[x][y]=(predSample[x][y+1]−predSample[x][y−1])>>Shift1

-   -   It should be noted that predSamples[x][y] keeps the precision         after interpolation.

b) How to Derive Δv for PROF

-   -   The derivation of Δv (denoted as dMvH[posX][posY] and         dMvV[posX][posY] with posX=0 . . . W−1, posY=0 . . . H−1) can be         described as below     -   Suppose the dimensions of the current block is cbWidth×cbHeight,         the number of control point motion vectors is numCpMv, and the         control point motion vectors are cpMvLX[cpIdx], with cpIdx=0 . .         . numCpMv−1 and X being 0 or 1 representing the two reference         lists.     -   The variables log 2CbW and log 2CbH are derived as follows:

log 2CbW=Log 2(cbWidth)

log 2CbH=Log 2(cbHeight)

-   -   The variables mvScaleHor, mvScaleVer, dHorX and dVerX are         derived as follows:

mvScaleHor=cpMvLX[0][0]<<7

mvScaleVer=cpMvLX[0][1]<<7

dHorX=(cpMvLX[1][0]−cpMvLX[0][0])<<(7−log 2CbW)

dVerX=(cpMvLX[1][1]−cpMvLX[0][1])<<(7−log 2CbW)

-   -   The variables dHorY and dVerY are derived as follows:         -   If numCpMv is equal to 3, the following applies:

dHorY=(cpMvLX[2][0]−cpMvLX[0][0])>>(7−log 2CbH)

dVerY=(cpMvLX[2][1]−cpMvLX[0][1])<<(7−log 2CbH)

-   -   -   Otherwise (numCpMv is equal to 2), the following applies:

dHorY=−dVerX

dVerY=dHorX

-   -   The variable qHorX, qVerX, qHorY and qVerY are derived as

qHorX=dHorX<<2;

qVerX=dVerX<<2;

qHorY=dHorY<<2;

qVerY=dVerY<<2;

-   -   dMvH[0][0] and dMvV[O][0] are calculated as

dMvH[0][0]=((dHorX+dHorY)<<1)−((qHorX+qHorY)<<1);

dMvV[0][0]=((dVerX+dVerY)<<1)−((qVerX+qVerY)<<1);

-   -   dMvH[xPos][0] and dMvV[xPos][0] forxPos from 1 to W−1 are         derived as:

dMvH[xPos][0]=dMvH[xPos−1][0]+qHorX;

dMvV[xPos][0]=dMvV[xPos−1][0]+qVerX;

For yPos from 1 to H−1, the following applies:

dMvH[xPos][yPos]=dMvH[xPos][yPos−1]+qHorY with xPos=0 . . . W−1

dMvV[xPos][yPos]=dMvV[xPos][yPos−1]+qVerY with xPos=0 . . . W−1

-   -   Finally, dMvH[xPos][yPos] and dMvV[xPos][yPos] with posX=0 . . .         W−1, posY=0 . . . H−1 are right shifted as

dMvH[xPos][yPos]=SatShift(dMvH[xPos][yPos],7+2−1);

dMvV[xPos][yPos]=SatShift(dMvV[xPos][yPos],7+2−1);

-   -   where SatShift(x, n) and Shift (x,n) is defined as

${{SatShift}\left( {x,n} \right)} = \left\{ {{{\begin{matrix} {\left( {x + {{offsset}\; 0}} \right)\operatorname{>>}n} & {if} & {x \geq 0} \\ {- \left( {\left( {{- x} + {{offset}\; 1}} \right)\operatorname{>>}n} \right)} & {if} & {x < 0} \end{matrix}{{Shift}\left( {x,n} \right)}} = \left( {x + {{offset}\; 0}} \right)}\operatorname{>>}n} \right.$

-   -   In one example, offset0 and/or offset1 are set to (1<<n)>>1.

c) How to Derive ΔI for PROF

-   -   For a position (posX, posY) inside a sub-block, its         corresponding Δv(i,j) is denoted as (dMvH[posX][posY],         dMvV[posX][posY]). Its corresponding gradients are denoted as         (gradientH[posX][posY], gradientV[posX][posY]).     -   Then ΔI(posX, posY) is derived as follows.     -   (dMvH[posX][posY], dMvV[posX][posY]) are clipped as

dMvH[posX][posY]=Clip3(−32768,32767,dMvH[posX][posY]);

dMvV[posX][posY]=Clip3(−32768,32767,dMvV[posX][posY]);

ΔI(posX,posY)=dMvH[posX][posY]×gradientH[posX][posY]+dMvV[posX][posY]×gradientV[posX][posY];

ΔI(posX,posY)=Shift(ΔI(posX,posY),1+1+4);

ΔI(posX,posY)=Clip3(−(2¹³−1),2¹³−1,ΔI(posX,posY));

d) How to Derive I′ for PROF

-   -   If the current block is not coded as bi-prediction or         weighted-prediction,

I′(posX,posY)=Shift((I(posX,posY)+ΔI(posX,posY)),Shift0),

I′(posX,posY)=ClipSample(I′(posX,posY)),

-   -   where Clip Sample clips a sample value to a valid output sample         value.     -   Then I′(posX, posY) is output as the inter-prediction value.     -   Otherwise (the current block is coded as bi-prediction or         weighted-prediction)         I′(posX, posY) will be stored and used to generate the         inter-prediction value according to other prediction values         and/or weighting values.

2.12 JVET-N0510

In JVET-N0510, phase-variant affine subblock motion compensation (MC) is proposed. The conventional two stage horizontal-vertical interpolation is applied. However, unlike the phase-invariant block-based MC that uses the same horizontal filter for all sample rows and the same vertical filter for all sample columns, different phases of filters can be applied to different sample rows and different sample columns in the affine subblock.

To better approximate the affine motion model in an affine subblock, phase-variant MC is applied to the subblock. In the proposed method, the affine coded block is also divided into 4×4 subblocks, and a subblock MV is derived for each subblock as done in VTM4.0. The MC of each subblock is divided into two stages. The first stage is to filter an (4+L−1)×(4+L−1) reference block window with (4+L−1) rows of horizontal filtering, where the L is the filter tap length of the interpolation filer. However, different from the translational MC, in the proposed phase-variant affine subblock MC, the filter phase of each sample row is different. For each sample row, MVx is derived as follows.

MVx=(subblockMVx<<7+dMvVerX×(rowIdx−L/2−2))>>7

The filter phase of each sample row is derived from the MVx. The subblockMVx is the x component of the MV of the derived subblockMV as done in VTM4.0. The rowIdx is the sample row index. The dMvVerX is (cuBottomLeftCPMVx−cuTopLeftCPMVx)<<(7−log 2LumaCbHeight), where cuBottomLeftCPMVx is the x component of the CU bottom left control point MV, cuTopLeftCPMVx is the x component of the CU top left control point MV, and LumaCbHeight is the log 2 of the height of the luma coding block (CB).

After the horizontal filtering, a 4×(4+L−1) horizontally filtered samples are generated. FIG. 26 shows the concept of the proposed horizontal filtering. The gray points are the samples of the reference block window, and the orange points denote the horizontally filtered samples. A blue tube of 8×1 samples denotes applying one time of 8-tap horizontal filtering, as shown in FIG. 26 and FIG. 27, respectively. Each sample row needs four times of horizontal filtering. The filter phases on a sample row are the same. However, the filter phases on different rows are different. Skewed 4×11 samples are generated.

In the second stage, the 4×(4+L−1) horizontally filtered samples (orange samples in FIG. 26) are further vertically filtered. For each sample column, MVy is derived as follows.

MVy=(subblockMVy<<7+dMvHorY×(columnIdx−2))>>7  (Equation 2)

The filter phase of each sample column is derived from the MVy. The subblockMVy is the y component of the MV of the derived subblock MV as done in VTM4.0. The columnIdx is the sample column index. The dMvHorY is (cuTopRightCPMVy−cuTopLeftCPMVy)<<(7−log 2LumaCbWidth), where cuTopRightCPMVy is the y component of the CU top right control point MV, cuTopLeftCPMVy is the y component of the CU top left control point MV, and log 2LumaCbWidth is the log 2 of the width of the luma CB.

After the vertical filtering, 4×4 affine subblock prediction samples are generated. FIG. 28 shows the concept of the proposed vertical filtering. The light orange points are the horizontally filtered samples from first stage. The red points are the vertically filtered samples as the final prediction samples.

In this proposal, the used interpolation filter sets are the same as those in VTM4.0. The only difference is that the horizontal filter phases on one sample row are different and the vertical filter phases on one sample column are different. As for the number of filtering operations for each affine subblock in the proposed method, it is the same as that in VTM4.0.

3. Drawbacks of Existing Implementations

Some existing implementations suffer from the following drawbacks:

-   -   (1) The gradients calculation methods are not identical in BDOF         and PROF.         -   (a) In BDOF, the gradients are calculated for the whole             block and padding is done once. In PROF, the gradients are             calculated for each sub-block and padding is done N times             (suppose there are N sub-blocks).         -   (b) PROF requires a higher precision for gradients than             BDOF.     -   (2) The interaction between PROF and other tools is unclear.     -   (3) It is unclear how to apply PROF on chroma components.     -   (4) The derivation process of Δv may be incorrect.     -   (5) PROF may be done conditionally for higher coding         performance.     -   (6) It is unclear how to combine the methods in JVET-N0236 and         JVET-N0510.     -   (7) The bit-width of dMvH and dMvV may be too large.         4. Example Methods for Prediction Refinement with Optical Flow         (PROF)

Embodiments of the presently disclosed technology overcome the drawbacks of existing implementations, thereby providing video coding with higher coding efficiencies. The methods for prediction refinement with optical flow, based on the disclosed technology, may enhance both existing and future video coding standards, is elucidated in the following examples described for various implementations. The examples of the disclosed technology provided below explain general concepts, and are not meant to be interpreted as limiting. In an example, unless explicitly indicated to the contrary, the various features described in these examples may be combined.

Denote reference picture of current picture from list 0 and list 1 by Ref0 and Ref1 respectively, denote τ₀=POC(current)−POC(Ref0), τ₁=POC(Ref1)−POC(current), and denote reference block of the current block from Ref0 and Ref1 by refblk0 and refblk1 respectively. For a subblock in current block, MV of its corresponding subblock in refblk0 pointing to refblk1 is denoted by (v_(x), v_(y)). MVs of the subblock in Ref0 and Ref1 are denoted by (mvL0_(x), mvL0_(y)) and (mvL1_(x), mvL1_(y)) respectively.

Shift(x, s) is defined as Shift(x, s)=(x+off)>>s

SignShift(x, s) is defined as

${Sat{{Shift}\left( {x,n} \right)}} = \left\{ \begin{matrix} {\left( {x + {{offs}{set}\; 0}} \right) ⪢ n} & {{{if}\mspace{14mu} x} \geq 0} \\ {- \left( {\left( {{- x} + {{offset}1}} \right) ⪢ n} \right)} & {{{if}\mspace{14mu} x} < 0} \end{matrix} \right.$

In an example, offset0 and/or offset1 are set to (1<<n)>>1 or (1<<(n−1)). In another example, offset0 and/or offset1 are set to 0. In yet another example, offset0=offset1=((1<<n)>>1)−1 or ((1<<(n−1)))−1.

Clip3(x, min, max) is defined as

${{Clip}\; 3\left( {{Min},{Max},x} \right)} = \left\{ \begin{matrix} {Min} & {{{if}\mspace{14mu} x} < {Min}} \\ {Max} & {{{if}\mspace{14mu} x} > {Max}} \\ x & {Otherwise} \end{matrix} \right.$

Herein, Max (a, b)=a>=b ? a: b, and Min (a, b)=a<=b ? a: b.

In the following discussion, an operation between two motion vectors means the operation will be applied to both the two components of the motion vector. For example, MV3=MV1+MV2 is equivalent to MV3_(x)=MV1_(x)+MV2_(x) and MV3_(y)=MV1_(y)+MV2_(y). alternatively, the operation may be only applied to the horizontal or vertical component of the two motion vectors. The term “absolute value” of a MV (MVx, MVy) may refer to abs(MVx), or abs(MVy), or max(abs(MVx), abs(MVy)) or abs(MVx)+abs(MVy), wherein function abs(x) returns absolute value of x, and function max(x, y) returns the larger one of x and y.

In the following discussion, the left neighboring block, left-bottom neighboring block, above neighboring block, right-above neighboring block and left-above neighboring block are denoted as block A₁, A₀, B₁, B₀ and B₂ as shown in FIG. 2.

-   -   1. It is proposed that the gradient calculation in PROF may be         done in a M×N region-level which is different from the sub-block         size used for motion compensation in affine mode.         -   a. In one example, the gradient calculation in PROF may be             done for a M×N region which is larger than a sub-block.         -   b. In one example, M and N may be some predefined number,             e.g. M=N=8 or M=N=16.         -   c. In one example, M and N may be some number defined             depending on the width/height for sub-block size, e.g.             M=N=2*Wmc wherein Wmc is the width/height for sub-block size             used in motion compensation.         -   d. The padding process used to derive the gradients in PROF             is done in a M×N region-level.         -   e. For all above examples, the definition of M and N are as             follows:             -   i. In one example, M=min(K0, block width) wherein K0 is                 an integer value.             -   ii. In one example, N=min (K1, block height) wherein K0                 is an integer value.             -   iii. For above examples, K0=K1=16.             -   iv. In one example, K0 and K1 are aligned with that used                 for BDOF.         -   f. The gradients of a first sample in a first sub-block may             be derived with a second sample in a second sub-block.             -   i. In one example, the second sub-block is adjacent to                 the first sub-block.             -   ii. In one example, the second sample is used to derive                 gradients of the first sample in the same way when it is                 in the first sub-block or in the second sub-block.             -   iii. The above methods may be applied when M×N is larger                 than a sub-block         -   g. One or multiple MVs may be derived for the padding             process for each M×N region.             -   i. In one example, one specific MV is derived for the                 padding process for a M×N region. Integer reference                 samples may be located with the specific MV, and then                 used to pad the samples out of M×N region.                 -   (i) In one example, the specific MV may be one MV of                     one sub-block in the M×N region, such as the                     top-left corner sub-block or a center sub-block in                     the M×N region. FIG. 31 shows an example. MV of the                     sub-block A, B, C, D, or E may be selected as the                     specific MV.                 -   (ii) In one example, the specific MV may be derived                     from the affine model toward a specific position                     (such as the center) of the M×N region.                 -   (iii) In one example, the specific MV may be derived                     from MVs of sub-blocks in the M×N region.                 -    a. For example, the specific MV may be derived as                     the average of the MVs of all sub-blocks in the M×N                     region.                 -    b. For example, the specific MV may be derived as                     the average of several MVs of the center sub-blocks.                 -    i. For example, the specific MV may be derived as                     the average of several MVs of B, C, D and E in FIG.                     31.                 -    ii. For example, the specific MV may be derived as                     the average of several MVs of B, and E in FIG. 31.                 -    iii. For example, the specific MV may be derived as                     the average of several MVs of C, and D in FIG. 31.                 -    c. For example, the specific MV may be derived as a                     function of multiple MVs (e.g., CPMVs or sub-blocks'                     MVs).             -   ii. In one example, multiple MVs are derived for the                 padding process for a M×N region. Integer reference                 samples may be located with the one of the multiple MVs,                 and then used to pad the samples out of M×N region.                 -   (i) In one example, when padding a first sample                     adjacent to a first sub-block of the M×N region, a                     first MV of the first sub-block may be used to                     locate the Integer reference sample(s), which is                     (are) used to pad the first sample.             -   iii. The above methods are applied when M×N is larger                 than a sub-block, and the padding process used to derive                 the gradients in PROF is done for each M×N region.     -   2. The gradient calculation in PROF/BIO may be done in a M×N         region-level and M/N may be adaptively changed.         -   a. In one example, M and N may depend on the dimensions W×H             of the current block.             -   i. For example, the region may be the whole current                 block, i.e. M=W and N=H.             -   ii. For example, M=W/T1 and N=H/T2, where T1 and T2 are                 integers, e.g. T1=T2=2.             -   iii. In one example, M and/or N may be signaled from the                 encoder to the decoder, such as in                 VPS/DPS/SPS/PPS/APS/slice header/tile group                 header/tile/CTU/CU.                 -   (i) Alternatively, M and/or N may be specified in                     the profiles/levels/tiers of a video coding                     standard.             -   iv. In one example, M=Min(W, T1) and N=Min(H, T2). For                 example, T1=T2=16.                 -   (i) In one example, T1 and/or T2 may be signaled                     from the encoder to the decoder, such as in                     VPS/DPS/SPS/PPS/APS/slice header/tile group                     header/tile/CTU/CU.                 -   (ii) Alternatively, T1 and/or T2 may be specified in                     the profiles/levels/tiers of a video coding                     standard.     -   3. For above methods, the followings may further apply:         -   a. In one example, M is at least equal to Mmin and N is at             least equal to Nmin, e.g. Mmin=Nmin=8.         -   b. In one example, the padding process is done once for each             M×N region to get a padded (M+dM)×(N+dN) region, e.g.             dM=dN=2.             -   i. In one example, the samples inside the region (such                 as the white circles in FIG. 23) may be derived from                 motion compensation with interpolation filtering.                 -   (i) In one example, the samples inside the region                     may be derived from motion compensation for several                     sub-blocks in the region.             -   ii. In one example, four side outer lines of samples                 (such as the black circles in FIG. 23) may be padded.                 -   (i) In one example, a sample to be padded may copy                     the intensity of the nearest integer sample in the                     reference block.                 -   (ii) In one example, a sample to be padded may copy                     the intensity of the nearest sample in the region                     that is not padded.     -   4. For each region that the gradient calculation in PROF/BIG is         applied, instead of calculating the gradient values for each         sample, it is proposed to calculate gradients based on partial         of samples.         -   a. In one example, gradients associated with samples at             given coordinates may be used in PROF/BIG, e.g., at (2x, y)             or (x, 2y) or (2x+1, 2y+1) or (2x, 2y) wherein (m, n) is the             coordinate relative to the top-left sample in the current             block.         -   b. In one example, samples may be firstly modified (e.g.,             downsampled) and modified samples may be used to derive             gradients.     -   5. It is proposed that the precision of gradient values         calculated in BDOF and PROF may be the same.         -   a. In one example, the sample difference may be shifted with             the same value.             -   i. In one example, the horizontal and/vertical gradients                 (denoted by gradientH, gradientV, respectively) may be                 calculated in the following way:

gradientH[x][y]=(predSamples[x+1][y]−predSample[x−1][y])>>Shift0

gradientV[x][y]=(predSample[x][y+1]−predSample[x][y−1])>>Shift1

Alternatively,

gradientH[x][y]=Shift((predSamples[x+1][y]−predSample[x−1][y]),Shift0)

gradientV[x][y]=Shift((predSample[x][y+1]−predSample[x][y−1]),Shift1)

Alternatively,

gradientH[x][y]=SatShift((predSamples[x+1][y]−predSample[x−1][y]),Shift0)

gradientV[x][y]=SatShift((predSample[x][y+1]−predSample[x][y−1]),Shift1)

-   -   -   -   ii. In one example, the horizontal and/vertical                 gradients (denoted by gradientH, gradientV,                 respectively) may be calculated in the following way:

gradientH[x][y]=(predSamples[x][y]*2−predSamples[x+1][y]−predSample[x−1][y])>>Shift0

gradientV[x][y]=(predSamples[x][y]*2−predSample[x][y+1]−predSample[x][y−1])>>Shift1

Alternatively,

gradientH[x][y]=Shift((predSamples[x][y]*2−predSamples[x+1][y]−predSample[x−1][y]),Shift0)

gradientV[x][y]=Shift((predSamples[x][y]*2−predSample[x][y+1]−predSample[x][y−1]),Shift1)

Alternatively,

gradientH[x][y]=SatShift((predSamples[x][y]*2−predSamples[x+1][y]−predSample[x−1][y]),Shift0)

gradientV[x][y]=SatShift((predSamples[x][y]*2−predSample[x][y+1]−predSample[x][y−1]),Shift1)

-   -   -   -   iii. In one example, Shift0 and/or Shift1 may be set to                 Max(2, (14−BitDepth)) wherein BitDepth is the bit depth                 of reconstructed sample/input sample.

    -   6. The following methods to pad the outer lines of samples         (denoted as padding samples, such as the black circles in         FIG. 23) may be applied to PROF, or to BIO, or to both PROF and         BIO.         -   a. The padding samples may be padded with the same method             for PROF and/or BIO. The “same method” may be any padding             method disclosed below.         -   b. In one example, the padding samples may be derived (e.g.             copied) from integer samples in the reference picture for             PROF and/or BIO.             -   i. In one example, the integer sample used to derive a                 padding sample may be located by the position of the                 padding sample, adding an MV, which may be rounded to an                 integer MV in the addition operation.                 -   (i) In one example, the MV (MvX, MvY) may be rounded                     to the flooring integer MV (IntX, IntY). For                     example, IntX=MvX>>P, IntY=MvY>>P, where P is the MV                     precision.                 -   (ii) In one example, the MV (MvX, MvY) may be                     rounded to the nearest integer MV (IntX, IntY). For                     example, set FracX=MvX & ((1<<P)−1), FracY=MvY &                     ((1<<P)−1), OffX=(FracX>=(1<<(P−1))) ? 1: 0,                     OffY=(FracY>=(1<<(P−1))) ? 1: 0, where P is the MV                     precision, then IntX=(MvX>>P)+OffX,                     IntY=(MvY>>P)+OffY. HalfFrac may be equal to                     1<<(P−1), in other examples, it may be equal to                     (1<<(P−1))−1 or (1<<(P−1))+1.                 -   (iii) In one example, the MV (MvX, MvY) may be                     rounded to the integer MV (IntX, IntY) as                     IntX=SatShift(MvX, P), IntY=SatShift(MvY, P) where P                     is the MV precision.                 -   (iv) In the above bullets, the MV precision P may                     depend on the color format and/or color components.                 -    a. For example, the MV precision for Cb/Cr                     components may be equal to the MV precision for the                     luma component plus K with the 4:2:0 color format.                     E.g. K may be equal to 1.                 -   (v) How to perform padding may be signaled from the                     encoder to the decoder, such as in                     VPS/DPS/SPS/PPS/APS/slice header/tile group                     header/tile/CTU/CU.                 -    a. Alternatively, how to perform padding may be                     specified in the profiles/levels/tiers of a video                     coding standard.                 -   (vi) How to perform padding may depend on block                     dimensions.

    -   7. It is proposed that when PROF is applied, the coding tool X         cannot be applied.         -   a. Alternatively, when coding tool X is applied, the PROF             cannot be applied.         -   b. In one example, if coding tool X cannot be applied, the             syntax element(s) to indicate coding tool X may not be             signaled.         -   c. In one example, coding tool X may be Generalized Bi             prediction (GBI).             -   i. For example, when GbiIdx is not equal to 0, PROF is                 not applied.             -   ii. Alternatively, when PROF is applied, GbiIdx must be                 0.             -   iii. Alternatively, when PROF is applied, GbiIdx is not                 signaled and inferred to be 0.             -   iv. Alternatively, when PROF is applied, GBI is not                 applied no matter GbiIdx is equal to 0 or not.         -   d. In one example, coding tool X may be local illumination             compensation.         -   e. In one example, coding tool X may be Multiple Transform             Set (MTS).             -   i. For example, when PROF is applied, only a default                 transform can be applied.                 -   (i) For example, when PROF is applied, syntax                     elements related MTS is not applied.         -   f. In one example, coding tool X may be weighted prediction.             -   i. For example, when unequal weights and/or unequal                 offsets due to weighted prediction are applied to one                 block, PROF is not applied.

    -   8. It is proposed that how to apply PROF may depend on the color         format and/or usage of separate plane coding.         -   a. In one example, PROF cannot be applied on chroma             components if the color format is 4:0:0.         -   b. In one example, PROF may be applied on chroma components             if the color format is 4:4:4.         -   c. In one example, PROF may be applied on chroma components             if the color format is unequal to 4:0:0.         -   d. In one example, how to derive delta MV (e.g., Δv in             Section 2.11) may depend on the color format.

    -   9. It is proposed that how to apply PROF may depend on the color         component.         -   a. In one example, gradients may be calculated independently             for each color component.             -   i. Alternatively, gradients calculated for a first color                 component may be used by a second color component.             -   ii. Alternatively, gradients may be calculated twice,                 one for the luma/main color component, and the other for                 two chroma/dependent color components.         -   b. In one example, delta MV (e.g., Δv in Section 2.11) may             be calculated independently for each color component.             -   i. Alternatively, delta MV calculated for a first color                 component may be used by a second color component.         -   c. In one example, prediction refinement (e.g., ΔI in             Section 2.11) may be calculated independently for each color             component.             -   i. Alternatively, prediction refinement (e.g., ΔI in                 Section 2.11) calculated for a first color component may                 be used by a second color component.         -   d. In one example, the precision of gradients in PROF may             depend on the color component.         -   e. In one example, the precision of delta MV (e.g., Δv in             Section 2.11) in PROF may depend on the color component.         -   f. In one example, whether and how to conduct the clipping             operations in PROF may depend on the color component.         -   g. In one example, whether and how to conduct the shifting             operations in PROF may depend on the color component.         -   h. In one example, PROF may be applied to luma component             only.         -   i. In one example, PROF may be applied to different color             components at different sub-block size.             -   i. Alternatively, PROF may be applied to different color                 components at same sub-block size.         -   j. In one example, PROF may be applied to chroma components             at M*N sub-block size.             -   i. For example, M and N are set equal to 4.         -   k. The above methods (bullet h-j) may further depend on the             color format (e.g., 4:2:0 or 4:4:4).

    -   10. It is proposed that the derivation of delta MV (e.g., Δv in         Section 2.11) may depend on the width and/or height of the         sub-block.         -   a. In one example dMvH[0][0] and dMvV[0][0] are calculated             as

qHorX=dHorX*P0;

qVerX=dVerX*P0;

qHorY=dHorY*P0;

qVerY=dVerY*P0;

dMvH[0][0]=((iDMvHorX+iDMvVerX)*P1)−(quadHorX*(blockWidth>>1)+quadVerX*(blockHeight*P1));

dMvV[0][0]=((iDMvHorY+iDMvVerY)*P1)−(quadHorY*(blockWidth>>1)+quadVerY*(blockHeight*P1));

-   -   -   where blockWidth and blockHeight represent the width and             height of sub-block, respectively. P0 and P1 are two numbers             controlling the precision.             -   i. For example, P0=4 and P1=2 then dMvH[0][0] and                 dMvV[0][0] are calculated as:

qHorX=dHorX<<2;

qVerX=dVerX<<2;

qHorY=dHorY<<2;

qVerY=dVerY<<2;

dMvH[0][0]=((iDMvHorX+iDMvVerX)<<1)−(quadHorX*(blockWidth>>1)+quadVerX*(blockHeight>>1));

dMvV[0][0]=((iDMvHorY+iDMvVerY)<<1)−(quadHorY*(blockWidth>>1)+quadVerY*(blockHeight>>1));

-   -   11. It is proposed that for affine coded blocks, PROF may be         done conditionally instead of always being applied.         -   a. In one example, whether and how to conduct PROF may             depend on the dimensions W×H of the current block.             -   i. For example, PROF may not be applied if W<=T1 and/or                 H<=T2, e.g. T1=T2=16;             -   ii. For example, PROF may not be applied if W<T1 and/or                 H<T2, e.g. T1=T2=16;             -   iii. For example, PROF may not be applied if W>=T1                 and/or H>=T2, e.g. T1=T2=64;             -   iv. For example, PROF may not be applied if W>T1 and/or                 H>T2, e.g. T1=T2=64;             -   v. For example, PROF may not be applied if W*H>T1 e.g.                 T1=64*64;             -   vi. For example, PROF may not be applied if W*H>=T1 e.g.                 T1=64*64;             -   vii. For example, PROF may not be applied if W*H<T1 e.g.                 T1=16*16;             -   viii. For example, PROF may not be applied if W*H<=T1                 e.g. T1=16*16;             -   ix. For example, PROF may not be applied if min(W,                 H)>=T1 e.g. T1=64;             -   x. For example, PROF may not be applied if min(W, H)>T1                 e.g. T1=64;             -   xi. For example, PROF may not be applied if max(W,                 H)<=T1 e.g. T1=16;             -   xii. For example, PROF may not be applied if max(W,                 H)<T1 e.g. T1=16;         -   b. In one example, whether and/or how to conduct PROF may             depend on control point motion vectors.         -   c. In one example, whether and/or how to conduct PROF may             depend on the affine parameters and/or the number of affine             parameters.             -   i. For the 4-parameter affine model, where

$\left\{ \begin{matrix} {{m{v^{h}\left( {x,y} \right)}} = {{ax} - {by} + {mv_{0}^{h}}}} \\ {{m{v^{v}\left( {x,y} \right)}} = {{bx} + {ay} + {mv_{0}^{v}}}} \end{matrix} \right.,$

-   -   -   -    whether and how to conduct PROF may depend on                 parameters a and b.             -   ii. For the 4-parameter affine model, where

$\left\{ {\begin{matrix} {{m{v^{h}\left( {x,y} \right)}} = {{ax} + {by} + {mv_{0}^{h}}}} \\ {{m{v^{v}\left( {x,y} \right)}} = {{cx} + {dy} + {mv_{0}^{v}}}} \end{matrix},} \right.$

-   -   -   -    whether and how to conduct PROF may depend on                 parameters a, b, c and d.             -   iii. In one example, PROF may not be applied if the                 maximum affine parameter is smaller (or not larger) than                 a threshold.                 -   (i) Alternatively, PROF may not be applied if all                     (such as four or six) affine parameters are smaller                     (or not larger) than a threshold.                 -   (ii) Alternatively, PROF may not be applied if at                     least one affine parameter is smaller (or not                     larger) than a threshold.             -   iv. In one example, PROF may not be applied if the                 maximum value of the absolute values of affine parameter                 is smaller (or not larger) than a threshold.                 -   (i) Alternatively, PROF may not be applied if the                     absolute values of all the affine parameters are                     smaller (or not larger) than a threshold.                 -   (ii) Alternatively, PROF can only be applied if at                     least one of the absolute values of all the affine                     parameters is larger (or not smaller) than a                     threshold.             -   v. In one example, PROF may not be applied if the                 minimum affine parameter is larger (or not smaller) than                 a threshold.                 -   (i) Alternatively, PROF may not be applied if all                     (such as four or six) affine parameters are larger                     (or not smaller) than a threshold.                 -   (ii) Alternatively, PROF may not be applied if at                     least one affine parameter is larger (or not                     smaller) than a threshold.             -   vi. In one example, PROF may not be applied if the                 minimum value of the absolute values of affine parameter                 is larger (or not smaller) than a threshold.                 -   (i) Alternatively, PROF may not be applied if the                     absolute values of all affine parameters are larger                     (or not smaller) than a threshold.                 -   (ii) Alternatively, PROF can only be applied if at                     least one of the absolute values of the affine                     parameters is smaller (or not larger) than a                     threshold.             -   vii. In one example, PROF may not be applied if the                 maximum value of the “absolute value” of the delta MV as                 disclosed in JVET-N0236 is smaller (or not larger) than                 a threshold.                 -   (i) Alternatively, PROF may not be applied if the                     “absolute value” of all the delta MVs are smaller                     (or not larger) than a threshold.                 -   (ii) Alternatively, PROF can only be applied if at                     least one of the “absolute value” of delta MV is                     larger (or not smaller) than a threshold.             -   viii. In one example, PROF may not be applied if the                 minimum value of the “absolute value” of the delta MV is                 larger (or not smaller) than a threshold.                 -   (i) Alternatively, PROF may not be applied if the                     “absolute value” of all the delta MVs are larger (or                     not smaller) than a threshold.                 -   (ii) Alternatively, PROF can only be applied if at                     least one of the “absolute value” of delta MV is                     larger (or not smaller) than a threshold.             -   ix. In one example, PROF may be applied to certain                 positions.                 -   (i) For example, PROF may be applied to a position                     if “absolute value” of its corresponding delta MV is                     smaller (or not larger) than a threshold.                 -   (ii) For example, PROF may be applied to a position                     if “absolute value” of its corresponding delta MV is                     larger (or not smaller) than a threshold.             -   x. In one example, the affine parameters may be                 represented as integers dHorX, dVerX, dHorY and dVerY                 with specific precisions as described in JVET-M1001.             -   xi. In one example, the threshold may depend on the                 bit-depth.                 -   (i) In one example, the threshold may be derived as                     1<<BitDepth.                 -   (ii) Alternatively, furthermore, the threshold may                     depend on whether bi-prediction or uni-prediction is                     applied.                 -    a. For example, the threshold may be derived as                     (1<<BitDepth)+(Bi-prediction? 1: 0).             -   xii. In one example, whether and/or how to apply the                 disclosed methods in bullet 11 may depend on the                 reference picture structure.                 -   (i) For example, if all reference pictures of the                     current picture are preceding the current picture in                     the display order, i.e. POCs of all the reference                     pictures are smaller than the POC of the current                     picture, one or multiple of the disclosed methods                     may not be applied.                 -   (ii) Alternatively, whether and/or how to apply the                     disclosed methods in bullet 11 may depend on                     slice/picture type (such as I-slice or B-slice).                 -   (iii) Alternatively, whether and/or how to apply the                     disclosed methods in bullet 11 may depend on the                     temporal layer.             -   xiii. In bullet 11, the coding method “PROF” may be                 replaced by other coding methods to enhance affine                 prediction coding, such as interweaved prediction as                 disclosed in JVET-N0216 or phase-variant affine subblock                 motion compensation.

    -   12. It is proposed that the phase-variant affine subblock motion         compensation, such as proposed in JVET-N0510, may be firstly         applied to get the prediction value, followed by PROF.

    -   13. It is proposed that the bit width of any variables used to         derive dMvH[x][y] and/or dMvV[x][y] for any valid x and y cannot         exceed a specific number, such as 32.         -   a. In one example, dMvH[x][y] and/or dMvV[x][y] are clipped             before being used to derive other dMvH[t][z] and/or             dMvV[t][z], where (t, z) is not equal to (x, y).         -   b. In one example, dMvH[x][y] and/or dMvV[x][y] are right             shifted before being used to derive other dMvH[t][z] and/or             dMvV[t][z], where (t, z) is not equal to (x, y).

    -   14. It is proposed that dMvH and/or dMvV may have the same         precision as stored motion vectors.         -   a. For example,

dMvH[xPos][yPos]=SatShift(dMvH[xPos][yPos],7+M);

dMvV[xPos][yPos]=SatShift(dMvV[xPos][yPos],7+M);

-   -    where M is the additional precision to derive dMvH and/or hMvV,         e.g. M=2.     -   15. It is proposed that the clipping on dMvH and/or dMvV before         being used to derive the prediction refinement ΔI may depend on         the precision of dMvH and/or dMvV.         -   a. For example

dMvH[posX][posY]=Clip3(−2^(K)−1,2^(K)−1−1,dMvH[posX][posY]);

dMvV[posX][posY]=Clip3(−2^(K)−1,2^(K)−1−1,dMvV[posX][posY]);

-   -   -   where K depends on the precision of dMvH and/or dMvV.         -   b. Alternatively, dMvH[x][y] and/or dMvV[x][y] are not             clipped before being used to derive the prediction             refinement.

    -   16. It is proposed that the right shift on the prediction         refinement ΔI(posX, posY) may depend on the sign of ΔI(posX,         posY).         -   a. For example, ΔI(posX, posY)=SatShift(ΔI(posX, posY),N),             where Nis an integer.

    -   17. It is proposed that the clipping on the prediction         refinement ΔI(posX, posY) may depend on the sample bit-depth.         -   a. For example ΔI(posX, posY)=Clip3(−(2^(3+BitDepth)−1),             2^(3+BitDepth)−1, ΔI(posX, posY));

    -   18. Whether and/or how to conduct deblocking is performed on         subblock boundaries within an affine mode block (e.g., inner         subblock boundaries) may depend on whether interweaved         prediction as disclosed in JVET-N0216 or/and PROF or/and         phase-variant affine subblock motion compensation is applied to         the block or not.         -   a. In one example, deblocking may be disabled when             interweaved prediction or/and PROF or/and phase-variant             affine subblock motion compensation is applied to the block.             -   i. Alternatively, deblocking filter may be weaker on                 sub-block boundaries where interweaved prediction or/and                 PROF or/and phase-variant affine subblock motion                 compensation is applied to the block. For example,                 boundary strength may be set smaller on such boundaries.         -   b. In one example, deblocking may be enabled when             interweaved prediction or/and PROF or/and phase-variant             affine subblock motion compensation is not applied to the             block.

The examples described above may be incorporated in the context of the methods described below, e.g., methods 2910 to 2950, which may be implemented at a video decoder or a video encoder.

FIG. 29A shows a flowchart of an exemplary method for video processing. The method 2910 includes, at step 2912, generating a prediction block for a current video block of a video using an affine mode motion compensation that is performed at a sub-block level of the current video block. The method 2910 further includes, at step 2914, performing a gradient calculation for a region of the current video block to refine the prediction block using a prediction refinement with optical flow (PROF) procedure, wherein a size of the region, (M×N), is different from a size of a sub-block of the current video block, wherein M and N are positive integers. The method 2910 further includes, at step 2916, performing, based on the gradient calculation, a conversion between the current video block and a coded representation of the video

FIG. 29B shows a flowchart of an exemplary method for video processing. The method 2920 includes, at step 2922, deriving, for a current video block of a video having a first size, a final prediction block that is computed by refining one or more intermediate prediction blocks using a gradient calculation performed on video regions having a second size according to a rule, wherein the refining uses an optical flow procedure. The method 2920 further includes, at step 2924, performing a conversion between the current video block and a coded representation of the video using the final prediction block.

FIG. 29C shows a flowchart of an exemplary method for video processing. The method 2930 includes, at step 2932, deriving, for a current video block of a video, motion information using a bidirectional optical flow (BDOF) or a prediction refinement with optical flow (PROF). The method 2930 further includes, at step 2934, performing a gradient calculation for samples in a region of the current video block such that at least one sample in the region is omitted from the gradient calculation. The method 2930 further includes, at step 2936, performing, based on the gradient calculation, a conversion between the current video block and a coded representation of a video comprising the current video block. In some implementations, one or more initial predictions for the current video block are computed at a sub-block level and refined using an optical flow calculation during the PROF or the one or more initial predictions are refined using a spatial and a temporal gradient during the BDOF.

FIG. 29D shows a flowchart of an exemplary method for video processing. The method 2940 includes, at step 2942, determining, for a current video block of a video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation based on a gradient of initial prediction samples according to a precision rule. The method 2940 further includes, at step 2944, performing a conversion between the current video block and a coded representation using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure or a bi-directional optical flow (BDOF) procedure, wherein the precision rule specifies to use a same precision for representing the gradient for both the PROF procedure and the BDOF procedure.

FIG. 29E shows a flowchart of an exemplary method for video processing. The method 2950 includes, at step 2952, determining, for conversion between a current video block of a video and a coded representation of the video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation. The method 2950 further includes, at step 2954, performing the conversion using the final prediction block. In some implementations, the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure and/or a bi-directional optical flow (BDOF) procedure, wherein the optical flow calculation further includes a padding operation applicable to at least one of the PROF procedure or the BDOF procedure according to a rule to derive padding samples.

5. Example Implementations of the Disclosed Technology

FIG. 30A is a block diagram of a video processing apparatus 3000. The apparatus 3000 may be used to implement one or more of the methods described herein. The apparatus 3000 may be embodied in a smartphone, tablet, computer, Internet of Things (IoT) receiver, and so on. The apparatus 3000 may include one or more processors 3002, one or more memories 3004 and video processing hardware 3006. The processor(s) 3002 may be configured to implement one or more methods (including, but not limited to, method 2900) described in the present document. The memory (memories) 3004 may be used for storing data and code used for implementing the methods and techniques described herein. The video processing hardware 3006 may be used to implement, in hardware circuitry, some techniques described in the present document.

FIG. 30B is another example of a block diagram of a video processing system in which disclosed techniques may be implemented. FIG. 30B is a block diagram showing an example video processing system 4100 in which various techniques disclosed herein may be implemented. Various implementations may include some or all of the components of the system 4100. The system 4100 may include input 4102 for receiving video content. The video content may be received in a raw or uncompressed format, e.g., 8 or 10 bit multi-component pixel values, or may be in a compressed or encoded format. The input 4102 may represent a network interface, a peripheral bus interface, or a storage interface. Examples of network interface include wired interfaces such as Ethernet, passive optical network (PON), etc. and wireless interfaces such as Wi-Fi or cellular interfaces.

The system 4100 may include a coding component 4104 that may implement the various coding or encoding methods described in the present document. The coding component 4104 may reduce the average bitrate of video from the input 4102 to the output of the coding component 4104 to produce a coded representation of the video. The coding techniques are therefore sometimes called video compression or video transcoding techniques. The output of the coding component 4104 may be either stored, or transmitted via a communication connected, as represented by the component 4106. The stored or communicated bitstream (or coded) representation of the video received at the input 4102 may be used by the component 4108 for generating pixel values or displayable video that is sent to a display interface 4110. The process of generating user-viewable video from the bitstream representation is sometimes called video decompression. Furthermore, while certain video processing operations are referred to as “coding” operations or tools, it will be appreciated that the coding tools or operations are used at an encoder and corresponding decoding tools or operations that reverse the results of the coding will be performed by a decoder.

Examples of a peripheral bus interface or a display interface may include universal serial bus (USB) or high definition multimedia interface (HDMI) or Displayport, and so on. Examples of storage interfaces include SATA (serial advanced technology attachment), PCI, IDE interface, and the like. The techniques described in the present document may be embodied in various electronic devices such as mobile phones, laptops, smartphones or other devices that are capable of performing digital data processing and/or video display.

Some embodiments of the disclosed technology include making a decision or determination to enable a video processing tool or mode. In an example, when the video processing tool or mode is enabled, the encoder will use or implement the tool or mode in the processing of a block of video, but may not necessarily modify the resulting bitstream based on the usage of the tool or mode. That is, a conversion from the block of video to the bitstream representation of the video will use the video processing tool or mode when it is enabled based on the decision or determination. In another example, when the video processing tool or mode is enabled, the decoder will process the bitstream with the knowledge that the bitstream has been modified based on the video processing tool or mode. That is, a conversion from the bitstream representation of the video to the block of video will be performed using the video processing tool or mode that was enabled based on the decision or determination.

Some embodiments of the disclosed technology include making a decision or determination to disable a video processing tool or mode. In an example, when the video processing tool or mode is disabled, the encoder will not use the tool or mode in the conversion of the block of video to the bitstream representation of the video. In another example, when the video processing tool or mode is disabled, the decoder will process the bitstream with the knowledge that the bitstream has not been modified using the video processing tool or mode that was disabled based on the decision or determination.

In the present document, the term “video processing” may refer to video encoding video decoding, video compression or video decompression. For example, video compression algorithms may be applied during conversion from pixel representation of a video to a corresponding bitstream representation or vice versa. The bitstream representation of a current video block may, for example, correspond to bits that are either co-located or spread in different places within the bitstream, as is defined by the syntax. For example, a macroblock may be encoded in terms of transformed and coded error residual values and also using bits in headers and other fields in the bitstream.

It will be appreciated that the disclosed methods and techniques will benefit video encoder and/or decoder embodiments incorporated within video processing devices such as smartphones, laptops, desktops, and similar devices by allowing the use of the techniques disclosed in the present document.

Various techniques and embodiments may be described using the following clause-based format.

The first set of clauses describe certain features and aspects of the disclosed techniques in the previous section.

1. A method for video processing, comprising: performing a gradient calculation in a first region of a current video block, wherein a size of the first region (M×N) is different from a size of a sub-block of the current video block that is used for motion compensation in an affine mode, and wherein M and N are positive integers; and performing, based on the gradient calculation, a conversion between the current video block and a bitstream representation of a video comprising the current video block.

2. The method of clause 1, wherein the size of the first region is larger than the size of the sub-block.

3. The method of clause 1 or 2, wherein M and N are predefined positive integers.

4. The method of clause 1 or 2, wherein the size of the first region is based on the size of the sub-block.

5. The method of clause 1, wherein M/N is adaptively changed.

6. The method of clause 1, wherein M and N are based on dimensions of the current video block.

7. The method of any of clauses 1 to 6, wherein M has a minimum value Mmin, and wherein N has a minimum value Nmin.

8. The method of clause 7, wherein Mmin=Nmin=8.

9. The method of any of clauses 1 to 6, wherein the first region is padded to generate a first padded region of size (M+dM)×(N+dN).

10. The method of clause 9, wherein samples in the first region or the first padded region are derived based on motion compensation with interpolation filtering.

11. The method of clause 1, wherein at least one sample in the first region is omitted when performing the gradient calculation.

12. The method of clause 1, wherein the gradient calculation is performed with a first precision in bi-directional optical flow (BDOF) and with a second precision in prediction refinement with optical flow (PROF), and wherein the first and second precisions are equal.

13. A method for video processing, comprising: making a decision, based on a selective application of a prediction refinement with optical flow (PROF) to a current video block, regarding a selective application of a coding tool to the current video block, wherein the coding tool is different from the PROF; and performing, based on the decision, a conversion between the current video block and a bitstream representation of a video comprising the current video block.

14. The method of clause 13, wherein the PROF is not applied and the coding tool is applied.

15. The method of clause 13, wherein the coding tool comprises generalized bi-prediction.

16. The method of clause 15, wherein the PROF is not applied, and wherein an index associated with the generalized bi-prediction is not zero.

17. The method of clause 13, wherein the coding tool is local illumination compensation.

18. The method of clause 13, wherein the coding tool is a multiple transform set (MTS).

19. The method of clause 18, wherein the PROF is applied, and only a default transform from the MTS is applied to the current video block.

20. The method of clause 13, wherein the coding tool is weighted prediction.

21. A method for video processing, comprising: making a decision, during a conversion between a current video block and a bitstream representation of a video comprising the current video block, regarding a selective application of a prediction refinement with optical flow (PROF) operation, wherein the decision is based on a color information of a current video block.

22. The method of clause 21, wherein the PROF operation is not applied to one or more chroma components of the current video block, and wherein the color information comprises a 4:0:0 color format.

23. The method of clause 21, wherein the PROF operation is applied to one or more chroma components of the current video block, and wherein the color information comprises a 4:4:4 color format.

24. The method of clause 21, wherein the PROF operation is applied to one or more chroma components of the current video block, and wherein the color information comprises a 4:0:0 color format.

25. The method of clause 21, wherein the PROF operation is applied, and wherein the color information comprises a plurality of color components

26. The method of clause 25, wherein one or more gradients of the PROF operation are calculated independently for each of the plurality of color components.

27. The method of clause 25, wherein one or more gradients of the PROF operation are calculated fora first color component of the plurality of color components and re-used fora second color component of the plurality of color components.

28. The method of clause 26 or 27, wherein a precision of the gradients is based on at least one of the plurality of color components.

29. A method for video processing, comprising: making a decision, based on a height (H) or a width (W) of a current video block, regarding a selective application of a prediction refinement with optical flow (PROF) operation; and performing, based on the decision, a conversion between the current video block and a bitstream representation of a video comprising the current video block.

30. The method of clause 29, wherein the PROF operation is applied to a luma component of the current video block.

31. The method of clause 29, wherein the current video block is coded using an affine mode.

32. The method of clause 31, wherein the PROF operation is not applied, wherein W<T1 and/or H≤T2, and wherein T1=T2=16.

33. The method of clause 31, wherein the PROF operation is not applied, wherein W>T1 and/or H>T2, and wherein T1=T2=64.

34. The method of clause 31, wherein the PROF operation is not applied, wherein W×H≤T or max(W, H)<T, and wherein T=16.

35. The method of clause 31, wherein the PROF operation is not applied, wherein W×H>T or min(W, H)>T, and wherein T=64.

36. The method of clause 1 or 2, wherein a size of the current video block is W×H, wherein M=min(K, W), and wherein K is an integer.

37. The method of clause 1 or 2, wherein a size of the current video block is W×H, wherein N=min(K, H), and wherein K is an integer.

38. The method of clause 36 or 37, wherein K=16.

39. The method of clause 1 or 2, further comprising: performing, prior to performing the gradient calculation, a padding process in the first region of the current video block.

40. The method of clause 39, wherein performing the padding process comprises deriving one or more motion vectors.

41. The method of clause 40, wherein the one or more motion vectors comprises a motion vector derived from an affine model toward a specific position of the first region.

42. The method of clause 40, wherein the one or more motion vectors comprises a motion vector derived from at least one motion vector of at least one sub-block of the first region.

43. The method of clause 39, wherein performing the padding process is based on a height or a width of the current video block.

44. The method of clause 39, wherein performing the padding process is based on signaling in a video parameter set (VPS), a decoder parameter set (DPS), a sequence parameter set (SPS), a picture parameter set (PPS), an adaptation parameter set (APS), a slice header, a tile, a tile group header, a coding tree unit (CTU) or a coding unit (CU).

45. The method of clause 5 or 6, wherein M and N are signaled in a video parameter set (VPS), a decoder parameter set (DPS), a sequence parameter set (SPS), a picture parameter set (PPS), an adaptation parameter set (APS), a slice header, a tile, a tile group header, a coding tree unit (CTU) or a coding unit (CU).

46. The method of clause 5 or 6, wherein M and N are specified in a profile, a level or a tier of a video coding standard.

47. An apparatus in a video system comprising a processor and a non-transitory memory with instructions thereon, wherein the instructions upon execution by the processor, cause the processor to implement the method in any one of clauses 1 to 46.

48. A computer program product stored on a non-transitory computer readable media, the computer program product including program code for carrying out the method in any one of clauses 1 to 46.

The second set of clauses describe certain features and aspects of the disclosed techniques in the previous section, including for example, Example Implementations 1 to 4.

1. A method for video processing, comprising: generating a prediction block for a current video block of a video using an affine mode motion compensation that is performed at a sub-block level of the current video block; performing a gradient calculation for a region of the current video block to refine the prediction block using a prediction refinement with optical flow (PROF) procedure, wherein a size of the region, (M×N), is different from a size of a sub-block of the current video block, wherein M and N are positive integers; and performing, based on the gradient calculation, a conversion between the current video block and a coded representation of the video.

2. The method of clause 1, wherein the size of the region is larger than the size of the sub-block.

3. The method of clause 1 or 2, wherein M and N are predefined positive integers.

4. The method of clause 1 or 2, wherein the size of the region is based on the size of the sub-block.

5. The method of clause 1, wherein a padding operation in the PROF procedure is applied to derive gradients at a (M×N) region level.

6. The method of any of clauses 1 to 5, wherein M is defined as min (K0, block width) and N is defined as min (K1, block height), whereby K0 and K1 are integers.

7. The method of clause 6, wherein K0 and K1 are equal to 16.

8. The method of clause 1, wherein the performing of the gradient calculation includes obtaining first gradients for a first sample in a first sub-block of the current video block and second gradients for a second sample in a second sub-block of the current video block.

9. The method of clause 8, wherein the second sub-block is adjacent to the first sub-block.

10. The method of clause 8, wherein the second sample is used to derive the first gradients.

11. The method of any of clauses 8 to 10, wherein the size of the region, (M×N), is larger than that of the sub-block of the current video block.

12. The method of clause 1, wherein one or more motion vectors are derived for a padding operation for the region.

13. The method of clause 12, wherein a specific motion vector that is associated with integer samples in a reference block of the current video block is derived for the padding operation for the region.

14. The method of clause 13, wherein the specific motion vector corresponds to a motion vector of one of sub-blocks in the region.

15. The method of clause 13, wherein the specific motion vector is derived by applying an affine model toward a specific position of the region.

16. The method of clause 13, wherein the specific motion vector is derived from motion vectors of all sub-blocks in the region.

17. The method of clause 13, wherein the specific motion vector is derived as an average of the motion vectors of all sub-blocks in the region.

18. The method of clause 13, wherein the specific motion vector is derived as an average of at least some motion vectors of sub-blocks in the region, the sub-blocks located around a center of the region.

19. The method of clause 13, wherein the specific motion vector is derived as a function of multiple motion vectors that include control point motion vectors or motion vectors of sub-blocks in the region.

20. The method of clause 12, wherein multiple motion vectors that are associated with integer samples in a reference block of the current video block are derived for the padding operation for the region.

21. The method of clause 20, wherein, for padding a first sample adjacent to a first sub-block of the region, a first motion vector of the first sub-block in the region is used to locate the integer samples.

22. The method of clause 12, wherein the size of the region, (M×N), is larger than that of the sub-block of the current video block.

23. The method of any of clauses 1 to 22, wherein minimum values of M and N are predetermined as Mmin and Nmin, respectively.

24. The method of clause 23, wherein Mmin=Nmin=8.

25. The method of any of clauses 1 to 24, wherein a padding operation is performed for the region to generate paddling samples in a padded region having a size of (M+dM)×(N+dN).

26. The method of clause 25, wherein samples inside the region are derived from a motion compensation with an interpolation filtering.

27. The method of clause 26, wherein the samples are derived from the motion compensation for several sub-blocks in the region.

28. The method of clause 25, wherein the paddling samples are derived along four outer sides of the region.

29. The method of clause 28, wherein a paddling sample copies an intensity of the nearest integer sample in a reference block of the current video block.

30. The method of clause 28, wherein a paddling sample copies an intensity of the nearest sample in the region that is not padded.

31. The method of any of clauses 1 to 30, wherein the performing of the conversion includes generating the coded representation from the current video block.

32. The method of any of clauses 1 to 30, wherein the performing of the conversion includes generating the current video block from the coded representation.

33. A method of video processing, comprising: deriving, for a current video block of a video having a first size, a final prediction block that is computed by refining one or more intermediate prediction blocks using a gradient calculation performed on video regions having a second size according to a rule, wherein the refining uses an optical flow procedure; and performing a conversion between the current video block and a coded representation of the video using the final prediction block.

34. The method of clause 33, wherein the rule specifies that the second size is a function of the first size.

35. The method of clause 34, wherein the rule specifies that a width (M) of the second size and/or a height (N) of the second size depends on a width (W) of the first size and/or a height (H) of the first size.

36. The method of clause 35, wherein M=W and N=H

37. The method of clause 35, wherein M=N=2*Wmc and Wmc is a width or a height of a sub-block of the current video block, the sub-block used to obtain the one or more intermediate prediction block using a motion compensation for the current video block.

38. The method of clause 35, wherein at least one of M and N is signaled in a video parameter set (VPS), a decoding parameter set (DPS), a sequence parameter set (SPS), a picture parameter set (PPS), an adaptation parameter set (APS), a slice header, a tile group header, a tile, a coding tree unit, or a coding unit.

39. The method of clause 35, wherein the at least one of M and N is specified in profiles, levels, or tiers of the rule.

40. The method of clause 35, wherein M=Min (W, T1) and N=Min (H, T2), whereby T1 and T2 are positive integers.

41. The method of clause 40, wherein at least one of T1 and T2 is signaled in a video parameter set (VPS), a decoding parameter set (DPS), a sequence parameter set (SPS), a picture parameter set (PPS), an adaptation parameter set (APS), a slice header, a tile group header, a tile, a coding tree unit, or a coding unit.

42. The method of clause 40, wherein at least one of T1 and T2 is specified in profiles, levels, or tiers of the rule.

43. The method of any of clauses 35 to 42, wherein minimum values of M and N are predetermined as Mmin and Nmin, respectively.

44. The method of clause 43, wherein Mmin=Nmin=8.

45. The method of any of clauses 33 to 44, wherein a padding operation is performed for the region to generate paddling samples in a padded region having a size of (M+dM)×(N+dN).

46. The method of clause 45, wherein samples inside the region are derived from a motion compensation with an interpolation filtering.

47. The method of clause 46, wherein the samples are derived from the motion compensation for several sub-blocks in the region.

48. The method of clause 45, wherein the paddling samples are derived along four outer sides of the region.

49. The method of clause 48, wherein a paddling sample copies an intensity of the nearest integer sample in a reference block of the current video block.

50. The method of clause 48, wherein a paddling sample copies an intensity of the nearest sample in the region that is not padded.

51. The method of clause 33, wherein the optical flow procedure comprises a prediction refinement with optical flow (PROF) procedure in which the one or more intermediate prediction blocks are computed at a sub-block level and refined using the optical flow calculation.

52. The method of clause 33, wherein the optical flow procedure comprises a bidirectional optical flow (BDOF) procedure in which the one or more intermediate predictions blocks are refined using a spatial and a temporal gradient.

53. The method of any of clauses 33 to 52, wherein the performing of the conversion includes generating the coded representation from the current video block.

54. The method of any of clauses 33 to 52, wherein the performing of the conversion includes generating the current video block from the coded representation.

55. A method for video processing, comprising: deriving, for a current video block of a video, motion information using a bidirectional optical flow (BDOF) or a prediction refinement with optical flow (PROF); performing a gradient calculation for samples in a region of the current video block such that at least one sample in the region is omitted from the gradient calculation; and performing, based on the gradient calculation, a conversion between the current video block and a coded representation of a video comprising the current video block, wherein one or more initial predictions for the current video block are computed at a sub-block level and refined using an optical flow calculation during the PROF or the one or more initial predictions are refined using a spatial and a temporal gradient during the BDOF.

56. The method of clause 55, wherein gradients associated with samples at given coordinates are used in the BIO and PROF.

57. The method of clause 55, wherein the samples are modified prior to the performing of the gradient calculation and modified samples are used during the performing of the gradient calculation.

58. The method of any of clauses 55 to 57, wherein the performing of the conversion includes generating the coded representation from the current video block.

59. The method of any of clauses 55 to 57, wherein the performing of the conversion includes generating the current video block from the coded representation.

The third set of clauses describe certain features and aspects of the disclosed techniques in the previous section, including for example, Example Implementations 5 and 6.

1. A video processing method, comprising: determining, for a current video block of a video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation based on a gradient of initial prediction samples according to a precision rule; and performing a conversion between the current video block and a coded representation using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure or a bi-directional optical flow (BDOF) procedure, wherein the precision rule specifies to use a same precision for representing the gradient for both the PROF procedure and the BDOF procedure.

2. The method of clause 1, wherein in the PROF procedure, the one or more initial predictions are computed at a sub-block level during affine motion compensated prediction and refined using the optical flow calculation.

3. The method of clause 1, wherein in the BDOF procedure, the one or more initial predictions are refined using at least one gradient value acquired during the optical flow calculation.

4. The method of clause 1, wherein horizontal gradients and vertical gradients that are respectively denoted as gradientH and gradientV are calculated as one of followings:

i) gradientH [x][y]=(predSamples [x+1][y]−predSample [x−1][y])>>Shift0, gradientV [x][y]=(predSample[x][y+1]−predSample [x][y−1])>>Shift1,

ii) gradientH [x][y]=Shift((predSamples [x+1][y]−predSample [x−1][y]), Shift0), gradientV [x][y]=Shift((predSample[x][y+1]−predSample [x][y−1]), Shift1),

iii) gradientH [x][y]=SatShift((predSamples [x+1][y]−predSample [x−1][y]), Shift0), gradientV [x][y]=SatShift((predSample[x][y+1]−predSample [x][y−1]), Shift1), or

iv) gradientH [x][y]=Shift(predSamples [x+1][y], Shift0)−Shift(predSample [x−1][y], Shift0), gradientV [x][y]=Shift(predSample[x][y+1], Shift0)−predSample [x][y−1], Shift1), and

wherein Shift (x, n) is defined as Shift (x, n)=(x+offset0)>>n and Satshift (x, n) is defined as

${{Sat}{{Shift}\left( {x,n} \right)}} = \left\{ \begin{matrix} {\left( {x + {{offs}{set}\; 0}} \right) ⪢ n} & {{{if}\mspace{14mu} x} \geq 0} \\ {- \left( {\left( {{- x} + {{offset}1}} \right) ⪢ n} \right)} & {{{if}\mspace{14mu} x} < 0} \end{matrix} \right.$

5. The method of clause 1, wherein horizontal gradients and vertical gradients that are respectively denoted as gradientH and gradientV are calculated as one of followings:

i) gradientH [x][y]=(predSamples [x][y]*2−predSamples [x+1][y]−predSample [x−1][y])>>Shift0, gradientV [x][y]=(predSamples [x][y]*2−predSample[x][y+1]−predSample [x][y−1])>>Shift1,

ii) gradientH [x][y]=Shift((predSamples [x][y]*2−predSamples [x+1][y]−predSample [x−1][y]), Shift0), gradientV [x][y]=Shift((predSamples [x][y]*2−predSample[x][y+1]−predSample [x][y−1]), Shift1), or

iii) gradientH [x][y]=SatShift((predSamples [x][y]*2−predSamples [x+1][y]−predSample [x−1][y]), Shift0), gradientV [x][y]=SatShift((predSamples [x][y]*2−predSample[x][y+1]−predSample [x][y−1]), Shift1), and

wherein Shift (x, n) is defined as Shift (x, n)=(x+offset0)>>n and Satshift (x, n) is defined as:

${{Sat}{{Shift}\left( {x,n} \right)}} = \left\{ \begin{matrix} {\left( {x + {{offs}{set}\; 0}} \right) ⪢ n} & {{{if}\mspace{14mu} x} \geq 0} \\ {- \left( {\left( {{- x} + {{offset}1}} \right) ⪢ n} \right)} & {{{if}\mspace{14mu} x} < 0} \end{matrix} \right.$

6. The method of clause 4 or 5, wherein Shift0 and/or Shift1 is set to Max (2, (14−BitDepth)) and wherein BitDepth represents a bit depth of a reconstructed sample or an input sample.

7. The method of any of clause 1 to 6, wherein Shift0 and/or Shift1 used in PROF and BDOF are same.

8. The method of any of clauses 1 to 7, wherein the performing of the conversion includes generating the coded representation from the current video block.

9. The method of any of clauses 1 to 7, wherein the performing of the conversion includes generating the current video block from the coded representation.

10. A video processing method, comprising: determining, for conversion between a current video block of a video and a coded representation of the video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation; and performing the conversion using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure and/or a bi-directional optical flow (BDOF) procedure, wherein the optical flow calculation further includes a padding operation applicable to at least one of the PROF procedure or the BDOF procedure according to a rule to derive padding samples.

11. The method of clause 10, wherein in the PROF procedure, the one or more initial predictions are computed at a sub-block level during affine motion compensated prediction and refined using the optical flow calculation.

12. The method of clause 10, wherein in the BDOF procedure, the one or more initial predictions are refined using at least one gradient value acquired during the optical flow calculation.

13. The method of clause 10, wherein the rule specifies to use a same padding operation for the PROF procedure and the BDOF procedure.

14. The method of clause 10, wherein the rule specifies to derive the padding samples from integer samples that are at integer positions in a reference picture of the current video block.

15. The method of clause 14, wherein an integer sample is located around a padding sample with a difference of MV (Mvx, Mvy) that is rounded to an integer MV.

16. The method of clause 14, wherein MV (Mvx, MvY) is rounded to a flooring integer (IntX, IntY).

17. The method of clause 14, wherein MV (Mvx, MvY) is rounded to a nearest integer MV (IntX, IntY).

18. The method of clause 14, wherein MV (Mvx, MvY) is rounded to an integer MV (IntX, IntY) such that IntX=SatShift(MvX, P) and IntY=SatShift(MvY, P), whereby P indicates a precision of MV and

${{Sat}{{Shift}\left( {x,n} \right)}} = \left\{ {\begin{matrix} {\left( {x + {{offs}{set}\; 0}} \right) ⪢ n} & {{{if}\mspace{14mu} x} \geq 0} \\ {- \left( {\left( {{- x} + {{offset}1}} \right) ⪢ n} \right)} & {{{if}\mspace{14mu} x} < 0} \end{matrix}.} \right.$

19. The method of any of clauses 15 to 18, wherein MV is rounded based on a precision of MV that depends on a color format and/or color component of the current video block.

20. The method of clause 10, wherein information how to perform the padding operation is signaled in a video parameter set (VPS), a decoding parameter set (DPS), a sequence parameter set (SPS), a picture parameter set (PPS), an adaptation parameter set (APS), a slice header, a tile group header, a tile, a coding tree unit, or a coding unit.

21. The method of clause 10, wherein information how to perform the padding operation is in profiles, levels, or tiers of the rule.

22. The method of clause 10, wherein information how to perform the padding operation depends on dimensions of the current video block.

23. The method of any of clauses 10 to 22, wherein the performing of the conversion includes generating the coded representation from the current video block.

24. The method of any of clauses 10 to 22, wherein the performing of the conversion includes generating the current video block from the coded representation.

25. An apparatus in a video system comprising a processor and a non-transitory memory with instructions thereon, wherein the instructions upon execution by the processor, cause the processor to implement the method in any one of clauses 10 to 22.

26. A computer program product stored on a non-transitory computer readable media, the computer program product including program code for carrying out the method in any one of clauses 10 to 22.

27. A video encoding method, comprising: determining, for encoding a current video block of a video into a coded representation of the video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation based on a gradient of motion according to a precision rule; and encoding the current video block into the coded representation using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure in which the one or more initial predictions are computed at a sub-block level and refined using the optical flow calculation and/or a bi-directional optical flow (BDOF) procedure in which the one or more initial predictions are refined using a spatial and a temporal gradient, wherein the precision rule specifies to use a same precision for representing the gradient for both the PROF procedure and the BDOF procedure.

28. A video decoding method, comprising: determining, for decoding a current video block of a video from a coded representation of the video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation based on a gradient of motion according to a precision rule; and generating a decoded current video block from the coded representation using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure in which the one or more initial predictions are computed at a sub-block level and refined using the optical flow calculation and/or a bi-directional optical flow (BDOF) procedure in which the one or more initial predictions are refined using a spatial and a temporal gradient, wherein the precision rule specifies to use a same precision for representing the gradient for both the PROF procedure and the BDOF procedure.

29. A video encoding method, comprising: determining, for encoding a current video block of a video into a coded representation of the video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation; and encoding the current video block into the coded representation using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure in which the one or more initial predictions are computed at a sub-block level and refined using the optical flow calculation and/or a bi-directional optical flow (BDOF) procedure in which the one or more initial predictions are refined using a spatial and a temporal gradient, wherein the optical flow calculation further includes a padding operation applicable to at least one of the PROF procedure or the BDOF procedure according to a rule to derive padding samples.

30. A video decoding method, comprising: determining, for decoding a current video block of a video from a coded representation of the video, a final prediction block for the current video block by refining one or more initial predictions for the current video block using an optical flow calculation; and generating a decoded current video block from the coded representation using the final prediction block, wherein the optical flow calculation includes a prediction refinement with optical flow (PROF) procedure in which the one or more initial predictions are computed at a sub-block level and refined using the optical flow calculation and/or a bi-directional optical flow (BDOF) procedure in which the one or more initial predictions are refined using a spatial and a temporal gradient, wherein the optical flow calculation further includes a padding operation applicable to at least one of the PROF procedure or the BDOF procedure according to a rule to derive padding samples.

From the foregoing, it will be appreciated that specific embodiments of the presently disclosed technology have been described herein for purposes of illustration, but that various modifications may be made without deviating from the scope of the invention. Accordingly, the presently disclosed technology is not limited except as by the appended claims.

Implementations of the subject matter and the functional operations described in this patent document can be implemented in various systems, digital electronic circuitry, or in computer software, firmware, or hardware, including the structures disclosed in this specification and their structural equivalents, or in combinations of one or more of them. Implementations of the subject matter described in this specification can be implemented as one or more computer program products, i.e., one or more modules of computer program instructions encoded on a tangible and non-transitory computer readable medium for execution by, or to control the operation of, data processing apparatus. The computer readable medium can be a machine-readable storage device, a machine-readable storage substrate, a memory device, a composition of matter effecting a machine-readable propagated signal, or a combination of one or more of them. The term “data processing unit” or “data processing apparatus” encompasses all apparatus, devices, and machines for processing data, including by way of example a programmable processor, a computer, or multiple processors or computers. The apparatus can include, in addition to hardware, code that creates an execution environment for the computer program in question, e.g., code that constitutes processor firmware, a protocol stack, a database management system, an operating system, or a combination of one or more of them.

A computer program (also known as a program, software, software application, script, or code) can be written in any form of programming language, including compiled or interpreted languages, and it can be deployed in any form, including as a stand-alone program or as a module, component, subroutine, or other unit suitable for use in a computing environment. A computer program does not necessarily correspond to a file in a file system. A program can be stored in a portion of a file that holds other programs or data (e.g., one or more scripts stored in a markup language document), in a single file dedicated to the program in question, or in multiple coordinated files (e.g., files that store one or more modules, sub programs, or portions of code). A computer program can be deployed to be executed on one computer or on multiple computers that are located at one site or distributed across multiple sites and interconnected by a communication network.

The processes and logic flows described in this specification can be performed by one or more programmable processors executing one or more computer programs to perform functions by operating on input data and generating output. The processes and logic flows can also be performed by, and apparatus can also be implemented as, special purpose logic circuitry, e.g., an FPGA (field programmable gate array) or an ASIC (application specific integrated circuit).

Processors suitable for the execution of a computer program include, by way of example, both general and special purpose microprocessors, and any one or more processors of any kind of digital computer. Generally, a processor will receive instructions and data from a read only memory or a random access memory or both. The essential elements of a computer are a processor for performing instructions and one or more memory devices for storing instructions and data. Generally, a computer will also include, or be operatively coupled to receive data from or transfer data to, or both, one or more mass storage devices for storing data, e.g., magnetic, magneto optical disks, or optical disks. However, a computer need not have such devices. Computer readable media suitable for storing computer program instructions and data include all forms of nonvolatile memory, media and memory devices, including by way of example semiconductor memory devices, e.g., EPROM, EEPROM, and flash memory devices. The processor and the memory can be supplemented by, or incorporated in, special purpose logic circuitry.

It is intended that the specification, together with the drawings, be considered exemplary only, where exemplary means an example. As used herein, the use of “or” is intended to include “and/or”, unless the context clearly indicates otherwise.

While this patent document contains many specifics, these should not be construed as limitations on the scope of any invention or of what may be claimed, but rather as descriptions of features that may be specific to particular embodiments of particular inventions. Certain features that are described in this patent document in the context of separate embodiments can also be implemented in combination in a single embodiment. Conversely, various features that are described in the context of a single embodiment can also be implemented in multiple embodiments separately or in any suitable subcombination. Moreover, although features may be described above as acting in certain combinations and even initially claimed as such, one or more features from a claimed combination can in some cases be excised from the combination, and the claimed combination may be directed to a subcombination or variation of a subcombination.

Similarly, while operations are depicted in the drawings in a particular order, this should not be understood as requiring that such operations be performed in the particular order shown or in sequential order, or that all illustrated operations be performed, to achieve desirable results. Moreover, the separation of various system components in the embodiments described in this patent document should not be understood as requiring such separation in all embodiments.

Only a few implementations and examples are described and other implementations, enhancements and variations can be made based on what is described and illustrated in this patent document. 

What is claimed is:
 1. A video processing method, comprising: determining, for a first block of a video which is coded with a non-affine mode, a first final prediction block for the first video block by refining one or more first initial predictions for the first video block using a first optical flow calculation procedure, wherein each first initial prediction is refined based on at least one gradient of the each first initial prediction; performing a first conversion between the first video block and a bitstream of the video using the first final prediction block; determining, for a second block of the video which is coded with an affine mode, a second final prediction block for the second video block by refining one or more second initial predictions for the second video block using a second optical flow calculation procedure, wherein each second initial prediction is refined based on at least one gradient of the each second initial prediction; and performing a second conversion between the second video block and the bitstream of the video using the second final prediction block, wherein a same padding operation is used for a reference block for calculating the gradient for the first optical flow calculation procedure and a reference block for calculating the gradient for the second optical flow calculation procedure, and wherein the reference block for calculating the gradient for the first optical flow calculation procedure and the reference block for calculating the gradient for the second optical flow calculation procedure are padded with integer samples.
 2. The method of claim 1, wherein the gradient for the first optical flow calculation procedure and the gradient for the second optical flow calculation procedure has a same precision.
 3. The method of claim 1, wherein the gradient for the first optical flow calculation procedure is calculated based on a first difference between multiple first initial prediction samples; and the gradient for the second optical flow calculation procedure is calculated based on a second difference between multiple second initial prediction samples.
 4. The method of claim 1, wherein the first optical flow calculation procedure is used only for a bi-direction inter prediction mode, and the second optical flow calculation procedure is used for the bi-prediction inter prediction mode and a uni-direction inter prediction mode.
 5. The method of claim 3, wherein first difference and the second difference are respectively right shifted with a same value to determine the gradient for the first optical flow calculation procedure and the gradient for the second optical flow calculation procedure.
 6. The method of claim 1, wherein a horizontal gradient and a vertical gradient of each first initial prediction (x, y) that are respectively denoted as gradientH and gradientV are calculated as one of followings: gradientH[x][y]=(predSamples[x+1][y]−predSample[x−1][y])>>Shift0, gradientV[x][y]=(predSample[x][y+1]−predSample[x][y−1])>>Shift1.
 7. The method of claim 1, wherein the padding operation is used to derive a above neighboring sample row, a below neighboring sample row, a left neighboring sample column, and a right neighboring sample column of the reference block for calculating the gradient for the first optical flow calculation procedure and the reference block for calculating the gradient for the second optical flow calculation procedure, and wherein the padding operation is applied by excluding an 8-tap interpolation filtering process.
 8. The method of claim 1, wherein the first optical flow calculation procedure is a bi-directional optical flow procedure, and the second optical flow calculation procedure is a prediction refinement with optical flow procedure.
 9. The method of claim 1, wherein the first conversion includes encoding the first video block into the bitstream and the second conversion comprises encoding the second video block into the bitstream.
 10. The method of claim 1, wherein the first conversion includes decoding the first video block from the bitstream and the second conversion comprises decoding the second video block from the bitstream.
 11. An apparatus for processing video data comprising a processor and a non-transitory memory with instructions thereon, wherein the instructions upon execution by the processor, cause the processor to: determine, for a first block of a video which is coded with a non-affine mode, a first final prediction block for the first video block by refining one or more first initial predictions for the first video block using a first optical flow calculation procedure, wherein each first initial prediction is refined based on at least one gradient of the each first initial prediction; perform a first conversion between the first video block and a bitstream of the video using the first final prediction block; determine, for a second block of the video which is coded with an affine mode, a second final prediction block for the second video block by refining one or more second initial predictions for the second video block using a second optical flow calculation procedure, wherein each second initial prediction is refined based on at least one gradient of the each second initial prediction; and perform a second conversion between the second video block and the bitstream of the video using the second final prediction block, wherein a same padding operation is used for a reference block for calculating the gradient for the first optical flow calculation procedure and a reference block for calculating the gradient for the second optical flow calculation procedure, and wherein the reference block for calculating the gradient for the first optical flow calculation procedure and the reference block for calculating the gradient for the second optical flow calculation procedure are padded with integer samples.
 12. The apparatus of claim 11, wherein the gradient for the first optical flow calculation procedure and the gradient for the second optical flow calculation procedure has a same precision.
 13. The apparatus of claim 11, wherein the gradient for the first optical flow calculation procedure is calculated based on a first difference between multiple first initial prediction samples; and the gradient for the second optical flow calculation procedure is calculated based on a second difference between multiple second initial prediction samples.
 14. The apparatus of claim 11, wherein the first optical flow calculation procedure is used only for a bi-direction inter prediction mode, and the second optical flow calculation procedure is used for the bi-prediction inter prediction mode and a uni-direction inter prediction mode.
 15. The apparatus of claim 13, wherein first difference and the second difference are respectively right shifted with a same value to determine the gradient for the first optical flow calculation procedure and the gradient for the second optical flow calculation procedure.
 16. The apparatus of claim 11, wherein a horizontal gradient and a vertical gradient of each first initial prediction (x, y) that are respectively denoted as gradientH and gradientV are calculated as one of followings: gradientH[x][y]=(predSamples[x+1][y]−predSample[x−1][y])>>Shift0, gradientV[x][y]=(predSample[x][y+1]−predSample[x][y−1])>>Shift1.
 17. The apparatus of claim 11, wherein a same padding operation is used for a reference block for calculating the gradient for the first optical flow calculation procedure and a reference block for calculating the gradient for the second optical flow calculation procedure.
 18. The apparatus of claim 11, wherein the reference block for calculating the gradient for the first optical flow calculation procedure and the reference block for calculating the gradient for the second optical flow calculation procedure are padded with integer samples.
 19. A non-transitory computer-readable storage medium storing instructions that cause a processor to: determine, for a first block of a video which is coded with a non-affine mode, a first final prediction block for the first video block by refining one or more first initial predictions for the first video block using a first optical flow calculation procedure, wherein each first initial prediction is refined based on at least one gradient of the each first initial prediction; perform a first conversion between the first video block and a bitstream of the video using the first final prediction block; determine, for a second block of the video which is coded with an affine mode, a second final prediction block for the second video block by refining one or more second initial predictions for the second video block using a second optical flow calculation procedure, wherein each second initial prediction is refined based on at least one gradient of the each second initial prediction; and perform a second conversion between the second video block and the bitstream of the video using the second final prediction block, wherein a same padding operation is used for a reference block for calculating the gradient for the first optical flow calculation procedure and a reference block for calculating the gradient for the second optical flow calculation procedure, and wherein the reference block for calculating the gradient for the first optical flow calculation procedure and the reference block for calculating the gradient for the second optical flow calculation procedure are padded with integer samples.
 20. A non-transitory computer-readable recording medium storing a bitstream of a video which is generated by a method performed by a video processing apparatus, wherein the method comprises: determining, for a first block of a video which is coded with a non-affine mode, a first final prediction block for the first video block by refining one or more first initial predictions for the first video block using a first optical flow calculation procedure, wherein each first initial prediction is refined with at least one gradient of the each first initial prediction; generating the bitstream based on the first final prediction block; determining, for a second block of the video which is coded with an affine mode, a second final prediction block for the second video block by refining one or more second initial predictions for the second video block using a second optical flow calculation procedure, wherein each second initial prediction is refined with at least one gradient of the each second initial prediction; and generating the bitstream based on the second final prediction block, wherein a same padding operation is used for a reference block for calculating the gradient for the first optical flow calculation procedure and a reference block for calculating the gradient for the second optical flow calculation procedure, and wherein the reference block for calculating the gradient for the first optical flow calculation procedure and the reference block for calculating the gradient for the second optical flow calculation procedure are padded with integer samples. 